(options imagebuilder.SimpleBuildOptions)
| 49 | } |
| 50 | |
| 51 | func (ref *Engine) Build(options imagebuilder.SimpleBuildOptions) (*imagebuilder.ImageResult, error) { |
| 52 | if len(options.ImageConfig.Config.Entrypoint) == 0 && |
| 53 | len(options.ImageConfig.Config.Cmd) == 0 { |
| 54 | return nil, fmt.Errorf("missing startup info") |
| 55 | } |
| 56 | |
| 57 | if len(options.Layers) == 0 { |
| 58 | return nil, fmt.Errorf("no layers") |
| 59 | } |
| 60 | |
| 61 | if len(options.Layers) > 255 { |
| 62 | return nil, fmt.Errorf("too many layers") |
| 63 | } |
| 64 | |
| 65 | switch options.ImageConfig.Architecture { |
| 66 | case "": |
| 67 | options.ImageConfig.Architecture = "amd64" |
| 68 | case "arm64", "amd64": |
| 69 | default: |
| 70 | return nil, fmt.Errorf("bad architecture value") |
| 71 | } |
| 72 | |
| 73 | var img v1.Image |
| 74 | if options.From == "" { |
| 75 | //same as FROM scratch |
| 76 | img = empty.Image |
| 77 | } else { |
| 78 | return nil, fmt.Errorf("custom base images are not supported yet") |
| 79 | } |
| 80 | |
| 81 | imgRunConfig := v1.Config{ |
| 82 | User: options.ImageConfig.Config.User, |
| 83 | ExposedPorts: options.ImageConfig.Config.ExposedPorts, |
| 84 | Env: options.ImageConfig.Config.Env, |
| 85 | Entrypoint: options.ImageConfig.Config.Entrypoint, |
| 86 | Cmd: options.ImageConfig.Config.Cmd, |
| 87 | Volumes: options.ImageConfig.Config.Volumes, |
| 88 | WorkingDir: options.ImageConfig.Config.WorkingDir, |
| 89 | Labels: options.ImageConfig.Config.Labels, |
| 90 | StopSignal: options.ImageConfig.Config.StopSignal, |
| 91 | ArgsEscaped: options.ImageConfig.Config.ArgsEscaped, |
| 92 | AttachStderr: options.ImageConfig.Config.AttachStderr, |
| 93 | AttachStdin: options.ImageConfig.Config.AttachStdin, |
| 94 | AttachStdout: options.ImageConfig.Config.AttachStdout, |
| 95 | Domainname: options.ImageConfig.Config.Domainname, |
| 96 | Hostname: options.ImageConfig.Config.Hostname, |
| 97 | Image: options.ImageConfig.Config.Image, |
| 98 | OnBuild: options.ImageConfig.Config.OnBuild, |
| 99 | OpenStdin: options.ImageConfig.Config.OpenStdin, |
| 100 | StdinOnce: options.ImageConfig.Config.StdinOnce, |
| 101 | Tty: options.ImageConfig.Config.Tty, |
| 102 | NetworkDisabled: options.ImageConfig.Config.NetworkDisabled, |
| 103 | MacAddress: options.ImageConfig.Config.MacAddress, |
| 104 | Shell: options.ImageConfig.Config.Shell, |
| 105 | } |
| 106 | |
| 107 | if options.ImageConfig.Config.Healthcheck != nil { |
| 108 | imgRunConfig.Healthcheck = &v1.HealthConfig{ |
nothing calls this directly
no test coverage detected