// Convert_v1_ImageLabel_To_build_ImageLabel is an autogenerated conversion function.
10837
func Convert_v1_ImageLabel_To_build_ImageLabel(in *v1.ImageLabel, out *build.ImageLabel, s conversion.Scope) error {
	return autoConvert_v1_ImageLabel_To_build_ImageLabel(in, out, s)
}
1205995
func Convert_v1_ImageImportSpec_To_image_ImageImportSpec(in *v1.ImageImportSpec, out *image.ImageImportSpec, s conversion.Scope) error {
	return autoConvert_v1_ImageImportSpec_To_image_ImageImportSpec(in, out, s)
}
185260
func (in *ImageLabel) DeepCopy() *ImageLabel {
	if in == nil {
		return nil
	}
	out := new(ImageLabel)
	in.DeepCopyInto(out)
	return out
}
1151881
func Convert_v1_ImageStreamImport_To_image_ImageStreamImport(in *v1.ImageStreamImport, out *image.ImageStreamImport, s conversion.Scope) error {
	return autoConvert_v1_ImageStreamImport_To_image_ImageStreamImport(in, out, s)
}
1002688
func Convert_image_Image_To_v1_Image(in *newer.Image, out *v1.Image, s conversion.Scope) error {
	out.ObjectMeta = in.ObjectMeta
	out.DockerImageReference = in.DockerImageReference
	out.DockerImageManifest = in.DockerImageManifest
	out.DockerImageManifestMediaType = in.DockerImageManifestMediaType
	out.DockerImageConfig = in.DockerImageConfig

	gvString := in.DockerImageMetadataVersion
	if len(gvString) == 0 {
		gvString = "1.0"
	}
	if !strings.Contains(gvString, "/") {
		gvString = "/" + gvString
	}

	version, err := schema.ParseGroupVersion(gvString)
	if err != nil {
		return err
	}
	data, err := runtime.Encode(dockerImageCodecs.LegacyCodec(version), &in.DockerImageMetadata)
	if err != nil {
		return err
	}
	out.DockerImageMetadata.Raw = data
	out.DockerImageMetadataVersion = version.Version

	if in.DockerImageLayers != nil {
		out.DockerImageLayers = make([]v1.ImageLayer, len(in.DockerImageLayers))
		for i := range in.DockerImageLayers {
			out.DockerImageLayers[i].MediaType = in.DockerImageLayers[i].MediaType
			out.DockerImageLayers[i].Name = in.DockerImageLayers[i].Name
			out.DockerImageLayers[i].LayerSize = in.DockerImageLayers[i].LayerSize
		}
	} else {
		out.DockerImageLayers = nil
	}

	if in.Signatures != nil {
		out.Signatures = make([]v1.ImageSignature, len(in.Signatures))
		for i := range in.Signatures {
			if err := s.Convert(&in.Signatures[i], &out.Signatures[i], 0); err != nil {
				return err
			}
		}
	} else {
		out.Signatures = nil
	}

	if in.DockerImageSignatures != nil {
		out.DockerImageSignatures = make([][]byte, 0, len(in.DockerImageSignatures))
		out.DockerImageSignatures = append(out.DockerImageSignatures, in.DockerImageSignatures...)
	} else {
		out.DockerImageSignatures = nil
	}

	return nil
}
848
func Convert_image_ImageLayerData_To_v1_ImageLayerData(in *image.ImageLayerData, out *v1.ImageLayerData, s conversion.Scope) error {
	return autoConvert_image_ImageLayerData_To_v1_ImageLayerData(in, out, s)
}
279695
func (b *Builder) BuildImage(image *Image) error {
	var layers []*ct.ImageLayer
	for _, l := range image.Layers {
		name := l.Name
		if name == "" {
			name = image.ID
		}

		env := make(map[string]string, len(image.Env)+len(l.Env))
		for k, v := range image.Env {
			env[k] = v
		}
		for k, v := range l.Env {
			env[k] = v
		}

		run := make([]string, len(l.Run))
		for i, cmd := range l.Run {
			run[i] = cmd
		}

		var inputs []string

		// add the script as an input and run with 'bash -e'
		if l.Script != "" {
			inputs = append(inputs, l.Script)
			run = append(run, "bash -e "+l.Script)
		}

		// add the explicit inputs, expanding globs
		for _, input := range l.Inputs {
			paths, err := filepath.Glob(input)
			if err != nil {
				return err
			}
			inputs = append(inputs, paths...)
		}

		// if building Go binaries, load Go inputs for the configured
		// GOOS / GOARCH and build with 'go build' / 'cgo build'
		if len(l.GoBuild) > 0 || len(l.CGoBuild) > 0 {
			goInputs := b.GoInputsFor(GoPlatform{OS: env["GOOS"], Arch: env["GOARCH"]})

			// add the commands in a predictable order so the
			// generated layer ID is deterministic
			dirs := make([]string, 0, len(l.GoBuild))
			for dir := range l.GoBuild {
				dirs = append(dirs, dir)
			}
			sort.Strings(dirs)
			for _, dir := range dirs {
				i, err := goInputs.Load(dir)
				if err != nil {
					return err
				}
				inputs = append(inputs, i...)
				run = append(run, fmt.Sprintf("go build -o %s %s", l.GoBuild[dir], filepath.Join("github.com/flynn/flynn", dir)))
			}
			dirs = make([]string, 0, len(l.CGoBuild))
			for dir := range l.CGoBuild {
				dirs = append(dirs, dir)
			}
			sort.Strings(dirs)
			for _, dir := range dirs {
				i, err := goInputs.Load(dir)
				if err != nil {
					return err
				}
				inputs = append(inputs, i...)
				run = append(run, fmt.Sprintf("cgo build -o %s %s", l.CGoBuild[dir], filepath.Join("github.com/flynn/flynn", dir)))
			}
		}

		// copy the l.Copy inputs in a predictable order so the
		// generated layer ID is deterministic
		copyPaths := make([]string, 0, len(l.Copy))
		for path := range l.Copy {
			copyPaths = append(copyPaths, path)
		}
		sort.Strings(copyPaths)
		for _, path := range copyPaths {
			inputs = append(inputs, path)
			dst := l.Copy[path]
			run = append(run, fmt.Sprintf("mkdir -p %q && cp %q %q", filepath.Dir(dst), path, dst))
		}

		// run the build job with either l.BuildWith or image.Base
		var artifact *ct.Artifact
		var err error
		if l.BuildWith != "" {
			artifact, err = b.Artifact(l.BuildWith)
		} else if image.Base != "" {
			artifact, err = b.Artifact(image.Base)
		}
		if err != nil {
			return err
		}

		// interpolate the environment variables
		for k, v := range env {
			tmpl, err := template.New("env").Parse(v)
			if err != nil {
				return fmt.Errorf("error parsing env template %q: %s", v, err)
			}
			var buf bytes.Buffer
			if err := tmpl.Execute(&buf, b.envTemplateData); err != nil {
				return fmt.Errorf("error parsing env template %q: %s", v, err)
			}
			env[k] = buf.String()
		}

		// generate the layer ID from the layer config, artifact and
		// list of inputs
		id, err := b.generateLayerID(name, run, env, artifact, inputs...)
		if err != nil {
			return err
		}

		start := time.Now()
		layer, err := b.BuildLayer(l, id, name, run, env, artifact, inputs)
		if err != nil {
			return err
		}
		b.log.Debug(fmt.Sprintf("%s layer done", name), "layer.id", id, "duration", time.Since(start))
		layers = append(layers, layer)
	}

	// generate an artifact based on image.Base and add to b.artifacts
	var baseLayers []*ct.ImageLayer
	if image.Base != "" {
		baseArtifact, err := b.Artifact(image.Base)
		if err != nil {
			return err
		}
		for _, rootfs := range baseArtifact.Manifest().Rootfs {
			baseLayers = append(baseLayers, rootfs.Layers...)
		}
	}
	manifest := ct.ImageManifest{
		Type: ct.ImageManifestTypeV1,
		Rootfs: []*ct.ImageRootfs{{
			Platform: ct.DefaultImagePlatform,
			Layers:   append(baseLayers, layers...),
		}},
	}
	if image.Entrypoint != nil {
		manifest.Entrypoints = map[string]*ct.ImageEntrypoint{
			"_default": image.Entrypoint,
		}
	}
	imageURL := fmt.Sprintf("%s?name=%s&target=/images/%s.json", b.tufConfig.Repository, image.ID, manifest.ID())
	artifact := &ct.Artifact{
		Type:             ct.ArtifactTypeFlynn,
		URI:              imageURL,
		RawManifest:      manifest.RawManifest(),
		Hashes:           manifest.Hashes(),
		Size:             int64(len(manifest.RawManifest())),
		LayerURLTemplate: layerURLTemplate,
		Meta: map[string]string{
			"manifest.id":        manifest.ID(),
			"flynn.component":    image.ID,
			"flynn.system-image": "true",
		},
	}
	b.artifactsMtx.Lock()
	b.artifacts[image.ID] = artifact
	b.artifactsMtx.Unlock()

	// write the artifact to build/image/ID.json
	path := filepath.Join("build", "image", image.ID+".json")
	if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
		return err
	}
	f, err := os.Create(path)
	if err != nil {
		return err
	}
	defer f.Close()
	return json.NewEncoder(f).Encode(artifact)
}
819152
func Convert_build_BinaryBuildSource_To_v1_BinaryBuildSource(in *build.BinaryBuildSource, out *v1.BinaryBuildSource, s conversion.Scope) error {
	return autoConvert_build_BinaryBuildSource_To_v1_BinaryBuildSource(in, out, s)
}
1026991
func Convert_kubeadm_ImageMeta_To_v1beta1_ImageMeta(in *kubeadm.ImageMeta, out *ImageMeta, s conversion.Scope) error {
	return autoConvert_kubeadm_ImageMeta_To_v1beta1_ImageMeta(in, out, s)
}
66972
func (c *Calcium) BuildImage(ctx context.Context, opts *enginetypes.BuildOptions) (chan *types.BuildImageMessage, error) {
	// Disable build API if scm not set
	if c.source == nil {
		return nil, types.ErrSCMNotSet
	}
	// select nodes
	node, err := c.selectBuildNode(ctx)
	if err != nil {
		return nil, err
	}
	log.Infof("[BuildImage] Building image at pod %s node %s", node.Podname, node.Name)
	// get refs
	refs := node.Engine.BuildRefs(ctx, opts.Name, opts.Tags)
	// support raw build
	buildContent := opts.Tar
	if opts.Builds != nil {
		buildContent, err = node.Engine.BuildContent(ctx, c.source, opts)
		if err != nil {
			return nil, err
		}
	}

	return c.doBuildImage(ctx, buildContent, node, refs)
}
986854
func Convert_v1_ImageImportStatus_To_image_ImageImportStatus(in *v1.ImageImportStatus, out *image.ImageImportStatus, s conversion.Scope) error {
	return autoConvert_v1_ImageImportStatus_To_image_ImageImportStatus(in, out, s)
}
1248617
func Convert_v1_RepositoryImportSpec_To_image_RepositoryImportSpec(in *v1.RepositoryImportSpec, out *image.RepositoryImportSpec, s conversion.Scope) error {
	return autoConvert_v1_RepositoryImportSpec_To_image_RepositoryImportSpec(in, out, s)
}
1213702
func Convert_image_ImageStreamMapping_To_v1_ImageStreamMapping(in *image.ImageStreamMapping, out *v1.ImageStreamMapping, s conversion.Scope) error {
	return autoConvert_image_ImageStreamMapping_To_v1_ImageStreamMapping(in, out, s)
}
591776
func Convert_v1_BuildStatus_To_build_BuildStatus(in *v1.BuildStatus, out *build.BuildStatus, s conversion.Scope) error {
	return autoConvert_v1_BuildStatus_To_build_BuildStatus(in, out, s)
}
684645
func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error) {
	if s.fieldLabelConversionFuncs[version] == nil {
		return "", "", fmt.Errorf("No field label conversion function found for version: %s", version)
	}
	conversionFunc, ok := s.fieldLabelConversionFuncs[version][kind]
	if !ok {
		return "", "", fmt.Errorf("No field label conversion function found for version %s and kind %s", version, kind)
	}
	return conversionFunc(label, value)
}
415673
func Convert_image_RepositoryImportStatus_To_v1_RepositoryImportStatus(in *image.RepositoryImportStatus, out *v1.RepositoryImportStatus, s conversion.Scope) error {
	return autoConvert_image_RepositoryImportStatus_To_v1_RepositoryImportStatus(in, out, s)
}
47633
func Convert_v1_BuildSource_To_build_BuildSource(in *v1.BuildSource, out *build.BuildSource, s conversion.Scope) error {
	return autoConvert_v1_BuildSource_To_build_BuildSource(in, out, s)
}