(project *types.Project)
| 163 | } |
| 164 | |
| 165 | func (opts createOptions) Apply(project *types.Project) error { |
| 166 | if opts.pullChanged { |
| 167 | if !opts.isPullPolicyValid() { |
| 168 | return fmt.Errorf("invalid --pull option %q", opts.Pull) |
| 169 | } |
| 170 | for i, service := range project.Services { |
| 171 | service.PullPolicy = opts.Pull |
| 172 | project.Services[i] = service |
| 173 | } |
| 174 | } |
| 175 | // N.B. opts.Build means "force build all", but images can still be built |
| 176 | // when this is false |
| 177 | // e.g. if a service has pull_policy: build or its local image is policy |
| 178 | if opts.Build { |
| 179 | for i, service := range project.Services { |
| 180 | if service.Build == nil { |
| 181 | continue |
| 182 | } |
| 183 | service.PullPolicy = types.PullPolicyBuild |
| 184 | project.Services[i] = service |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | if err := applyPlatforms(project, true); err != nil { |
| 189 | return err |
| 190 | } |
| 191 | |
| 192 | err := applyScaleOpts(project, opts.scale) |
| 193 | if err != nil { |
| 194 | return err |
| 195 | } |
| 196 | return nil |
| 197 | } |
| 198 | |
| 199 | func applyScaleOpts(project *types.Project, opts []string) error { |
| 200 | for _, scale := range opts { |
no test coverage detected