func projectReload(p *project.Project, useNetwork *bool, loadConsole bool, environmentLookup *docker.ConfigEnvironment, authLookup *docker.ConfigAuthLookup) func() error { enabled := map[interface{}]interface{}{} return func() error { cfg := config.LoadConfig() environmentLookup.SetConfig(cfg) authLookup.SetConfig(cfg) enabled = addServices(p, enabled, cfg.Rancher.Services) for service, serviceEnabled := range cfg.Rancher.ServicesInclude { if _, ok := enabled[service]; ok || !serviceEnabled { continue } if err := LoadService(p, cfg, *useNetwork, service); err != nil { if err != network.ErrNoNetwork { log.Error(err) } continue } enabled[service] = service } if !loadConsole || cfg.Rancher.Console == "" || cfg.Rancher.Console == "default" { return nil } if err := LoadService(p, cfg, *useNetwork, cfg.Rancher.Console); err != nil && err != network.ErrNoNetwork { log.Error(err) } return nil } }
func newProject(name string, cfg *config.CloudConfig, environmentLookup composeConfig.EnvironmentLookup, authLookup *rosDocker.ConfigAuthLookup) (*project.Project, error) { clientFactory, err := rosDocker.NewClientFactory(composeClient.Options{}) if err != nil { return nil, err } if environmentLookup == nil { environmentLookup = rosDocker.NewConfigEnvironment(cfg) } if authLookup == nil { authLookup = rosDocker.NewConfigAuthLookup(cfg) } serviceFactory := &rosDocker.ServiceFactory{ Deps: map[string][]string{}, } context := &docker.Context{ ClientFactory: clientFactory, AuthLookup: authLookup, Context: project.Context{ ProjectName: name, EnvironmentLookup: environmentLookup, ServiceFactory: serviceFactory, LoggerFactory: logger.NewColorLoggerFactory(), }, } serviceFactory.Context = context authLookup.SetContext(context) return docker.NewProject(context, &composeConfig.ParseOptions{ Interpolate: true, Validate: false, Preprocess: preprocessServiceMap, }) }