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

Method Apply

pkg/api/api.go:232–260  ·  view source on GitHub ↗

Apply mutates project according to build options

(project *types.Project)

Source from the content-addressed store, hash-verified

230
231// Apply mutates project according to build options
232func (o BuildOptions) Apply(project *types.Project) error {
233 platform := project.Environment["DOCKER_DEFAULT_PLATFORM"]
234 for name, service := range project.Services {
235 if service.Provider == nil && service.Image == "" && service.Build == nil {
236 return fmt.Errorf("invalid service %q. Must specify either image or build", name)
237 }
238
239 if service.Build == nil {
240 continue
241 }
242 if platform != "" {
243 if len(service.Build.Platforms) > 0 && !slices.Contains(service.Build.Platforms, platform) {
244 return fmt.Errorf("service %q build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: %s", name, platform)
245 }
246 service.Platform = platform
247 }
248 if service.Platform != "" {
249 if len(service.Build.Platforms) > 0 && !slices.Contains(service.Build.Platforms, service.Platform) {
250 return fmt.Errorf("service %q build configuration does not support platform: %s", name, service.Platform)
251 }
252 }
253
254 service.Build.Pull = service.Build.Pull || o.Pull
255 service.Build.NoCache = service.Build.NoCache || o.NoCache
256
257 project.Services[name] = service
258 }
259 return nil
260}
261
262// CreateOptions group options of the Create API
263type CreateOptions struct {

Callers 1

BuildMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected