MCPcopy
hub / github.com/docker/compose / postProcessProject

Method postProcessProject

pkg/compose/loader.go:120–157  ·  view source on GitHub ↗

postProcessProject applies post-loading transformations to the project

(project *types.Project, options api.ProjectLoadOptions)

Source from the content-addressed store, hash-verified

118
119// postProcessProject applies post-loading transformations to the project
120func (s *composeService) postProcessProject(project *types.Project, options api.ProjectLoadOptions) (*types.Project, error) {
121 if project.Name == "" {
122 return nil, errors.New("project name can't be empty. Use ProjectName option to set a valid name")
123 }
124
125 project, err := project.WithServicesEnabled(options.Services...)
126 if err != nil {
127 return nil, err
128 }
129
130 // Add custom labels
131 for name, s := range project.Services {
132 s.CustomLabels = map[string]string{
133 api.ProjectLabel: project.Name,
134 api.ServiceLabel: name,
135 api.VersionLabel: api.ComposeVersion,
136 api.WorkingDirLabel: project.WorkingDir,
137 api.ConfigFilesLabel: strings.Join(project.ComposeFiles, ","),
138 api.OneoffLabel: "False",
139 }
140 if len(options.EnvFiles) != 0 {
141 s.CustomLabels[api.EnvironmentFileLabel] = strings.Join(options.EnvFiles, ",")
142 }
143 project.Services[name] = s
144 }
145
146 project, err = project.WithSelectedServices(options.Services)
147 if err != nil {
148 return nil, err
149 }
150
151 // Remove unnecessary resources if not All
152 if !options.All {
153 project = project.WithoutUnnecessaryResources()
154 }
155
156 return project, nil
157}

Callers 1

LoadProjectMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected