image/oci.go
func (m *manifestOCI1) UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error) {
	copy := manifestOCI1{ // NOTE: This is not a deep copy, it still shares slices etc.
		src:        m.src,
		configBlob: m.configBlob,
		m:          manifest.OCI1Clone(m.m),
	}
	if options.LayerInfos != nil {
		if err := copy.m.UpdateLayerInfos(options.LayerInfos); err != nil {
			return nil, err
		}
	}
	// Ignore options.EmbeddedDockerReference: it may be set when converting from schema1, but we really don't care.

	switch options.ManifestMIMEType {
	case "": // No conversion, OK
	case manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema1SignedMediaType:
		// We can't directly convert to V1, but we can transitively convert via a V2 image
		m2, err := copy.convertToManifestSchema2()
		if err != nil {
			return nil, err
		}
		return m2.UpdatedImage(ctx, types.ManifestUpdateOptions{
			ManifestMIMEType: options.ManifestMIMEType,
			InformationOnly:  options.InformationOnly,
		})
	case manifest.DockerV2Schema2MediaType:
		return copy.convertToManifestSchema2()
	default:
		return nil, errors.Errorf("Conversion of image manifest from %s to %s is not implemented", imgspecv1.MediaTypeImageManifest, options.ManifestMIMEType)
	}

	return memoryImageFromManifest(&copy), nil
}
func (m *manifestOCI1) UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error) {
	copy := manifestOCI1{ // NOTE: This is not a deep copy, it still shares slices etc.
		src:        m.src,
		configBlob: m.configBlob,
		m:          manifest.OCI1Clone(m.m),
	}
	if options.LayerInfos != nil {
		if err := copy.m.UpdateLayerInfos(options.LayerInfos); err != nil {
			return nil, err
		}
	}
	// Ignore options.EmbeddedDockerReference: it may be set when converting from schema1, but we really don't care.

	switch options.ManifestMIMEType {
	case "": // No conversion, OK
	case manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema1SignedMediaType:
		// We can't directly convert to V1, but we can transitively convert via a V2 image
		m2, err := copy.convertToManifestSchema2()
		if err != nil {
			return nil, err
		}
		return m2.UpdatedImage(ctx, types.ManifestUpdateOptions{
			ManifestMIMEType: options.ManifestMIMEType,
			InformationOnly:  options.InformationOnly,
		})
	case manifest.DockerV2Schema2MediaType:
		return copy.convertToManifestSchema2()
	default:
		return nil, errors.Errorf("Conversion of image manifest from %s to %s is not implemented", imgspecv1.MediaTypeImageManifest, options.ManifestMIMEType)
	}

	return memoryImageFromManifest(&copy), nil
}
func ( m * manifestOCI1 ) UpdatedImage ( ctx context . Context , options types . ManifestUpdateOptions ) ( types . Image , error ) { copy := manifestOCI1 { // NOTE: This is not a deep copy, it still shares slices etc. src : m . src , configBlob : m . configBlob , m : manifest . OCI1Clone ( m . m ) , } if options . LayerInfos != nil { if err := copy . m . UpdateLayerInfos ( options . LayerInfos ) ; err != nil { return nil , err } } // Ignore options.EmbeddedDockerReference: it may be set when converting from schema1, but we really don't care. switch options . ManifestMIMEType { case " " : // No conversion, OK case manifest . DockerV2Schema1MediaType , manifest . DockerV2Schema1SignedMediaType : // We can't directly convert to V1, but we can transitively convert via a V2 image m2 , err := copy . convertToManifestSchema2 ( ) if err != nil { return nil , err } return m2 . UpdatedImage ( ctx , types . ManifestUpdateOptions { ManifestMIMEType : options . ManifestMIMEType , InformationOnly : options . InformationOnly , } ) case manifest . DockerV2Schema2MediaType : return copy . convertToManifestSchema2 ( ) default : return nil , errors . Errorf ( " " , imgspecv1 . MediaTypeImageManifest , options . ManifestMIMEType ) } return memoryImageFromManifest ( & copy ) , nil }
// UpdatedImage returns a types.Image modified according to options.
// This does not change the state of the original Image object.
UpdatedImage returns a types . Image modified according to options . This does not change the state of the original Image object .