(project *types.Project, service *types.ServiceConfig, opts api.RunOptions)
| 224 | } |
| 225 | |
| 226 | func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts api.RunOptions) { |
| 227 | service.Tty = opts.Tty |
| 228 | service.StdinOpen = opts.Interactive |
| 229 | service.ContainerName = opts.Name |
| 230 | |
| 231 | if len(opts.Command) > 0 { |
| 232 | service.Command = opts.Command |
| 233 | } |
| 234 | if opts.User != "" { |
| 235 | service.User = opts.User |
| 236 | } |
| 237 | |
| 238 | if len(opts.CapAdd) > 0 { |
| 239 | service.CapAdd = append(service.CapAdd, opts.CapAdd...) |
| 240 | service.CapDrop = slices.DeleteFunc(service.CapDrop, func(e string) bool { return slices.Contains(opts.CapAdd, e) }) |
| 241 | } |
| 242 | if len(opts.CapDrop) > 0 { |
| 243 | service.CapDrop = append(service.CapDrop, opts.CapDrop...) |
| 244 | service.CapAdd = slices.DeleteFunc(service.CapAdd, func(e string) bool { return slices.Contains(opts.CapDrop, e) }) |
| 245 | } |
| 246 | if opts.WorkingDir != "" { |
| 247 | service.WorkingDir = opts.WorkingDir |
| 248 | } |
| 249 | if opts.Entrypoint != nil { |
| 250 | service.Entrypoint = opts.Entrypoint |
| 251 | if len(opts.Command) == 0 { |
| 252 | service.Command = []string{} |
| 253 | } |
| 254 | } |
| 255 | if len(opts.Environment) > 0 { |
| 256 | cmdEnv := types.NewMappingWithEquals(opts.Environment) |
| 257 | serviceOverrideEnv := cmdEnv.Resolve(func(s string) (string, bool) { |
| 258 | v, ok := envResolver(project.Environment)(s) |
| 259 | return v, ok |
| 260 | }).RemoveEmpty() |
| 261 | if service.Environment == nil { |
| 262 | service.Environment = types.MappingWithEquals{} |
| 263 | } |
| 264 | service.Environment.OverrideBy(serviceOverrideEnv) |
| 265 | } |
| 266 | for k, v := range opts.Labels { |
| 267 | service.Labels = service.Labels.Add(k, v) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func (s *composeService) resolveRunServiceReferences(ctx context.Context, projectName string, service *types.ServiceConfig) error { |
| 272 | containersByService, err := s.getContainersByService(ctx, projectName) |
no test coverage detected