(capAdd []string, capDrop []string)
| 410 | } |
| 411 | |
| 412 | func (cr *containerReference) create(capAdd []string, capDrop []string) common.Executor { |
| 413 | return func(ctx context.Context) error { |
| 414 | if cr.id != "" { |
| 415 | return nil |
| 416 | } |
| 417 | logger := common.Logger(ctx) |
| 418 | isTerminal := term.IsTerminal(int(os.Stdout.Fd())) |
| 419 | input := cr.input |
| 420 | |
| 421 | config := &container.Config{ |
| 422 | Image: input.Image, |
| 423 | WorkingDir: input.WorkingDir, |
| 424 | Env: input.Env, |
| 425 | ExposedPorts: convertPortSet(input.ExposedPorts), |
| 426 | Tty: isTerminal, |
| 427 | } |
| 428 | logger.Debugf("Common container.Config ==> %+v", config) |
| 429 | |
| 430 | if len(input.Cmd) != 0 { |
| 431 | config.Cmd = input.Cmd |
| 432 | } |
| 433 | |
| 434 | if len(input.Entrypoint) != 0 { |
| 435 | config.Entrypoint = input.Entrypoint |
| 436 | } |
| 437 | |
| 438 | mounts := make([]mount.Mount, 0) |
| 439 | for mountSource, mountTarget := range input.Mounts { |
| 440 | mounts = append(mounts, mount.Mount{ |
| 441 | Type: mount.TypeVolume, |
| 442 | Source: mountSource, |
| 443 | Target: mountTarget, |
| 444 | }) |
| 445 | } |
| 446 | |
| 447 | var platSpecs *specs.Platform |
| 448 | if supportsContainerImagePlatform(ctx, cr.cli) && cr.input.Platform != "" { |
| 449 | desiredPlatform := strings.SplitN(cr.input.Platform, `/`, 2) |
| 450 | |
| 451 | if len(desiredPlatform) != 2 { |
| 452 | return fmt.Errorf("incorrect container platform option '%s'", cr.input.Platform) |
| 453 | } |
| 454 | |
| 455 | platSpecs = &specs.Platform{ |
| 456 | Architecture: desiredPlatform[1], |
| 457 | OS: desiredPlatform[0], |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | hostConfig := &container.HostConfig{ |
| 462 | CapAdd: capAdd, |
| 463 | CapDrop: capDrop, |
| 464 | Binds: input.Binds, |
| 465 | Mounts: mounts, |
| 466 | NetworkMode: container.NetworkMode(input.NetworkMode), |
| 467 | Privileged: input.Privileged, |
| 468 | UsernsMode: container.UsernsMode(input.UsernsMode), |
| 469 | PortBindings: convertPortMap(input.PortBindings), |
no test coverage detected