Documentation ¶
Index ¶
- Constants
- func CreateResolver(cfg *configfile.ConfigFile, plainHTTPRegistries ...string) remotes.Resolver
- func FixupBundle(ctx context.Context, b *bundle.Bundle, ref reference.Named, ...) (relocation.ImageRelocationMap, error)
- func Pull(ctx context.Context, ref reference.Named, resolver remotes.Resolver) (*bundle.Bundle, relocation.ImageRelocationMap, error)
- func Push(ctx context.Context, b *bundle.Bundle, ...) (ocischemav1.Descriptor, error)
- type DescriptorProgressSnapshot
- type FixupEvent
- type FixupEventType
- type FixupOption
- func WithAutoBundleUpdate() FixupOption
- func WithComponentImagePlatforms(supportedPlatforms []string) FixupOption
- func WithEventCallback(callback func(FixupEvent)) FixupOption
- func WithInvocationImagePlatforms(supportedPlatforms []string) FixupOption
- func WithParallelism(maxConcurrentJobs int, jobsBufferLength int) FixupOption
- func WithPushImages(imageClient internal.ImageClient, out io.Writer) FixupOption
- func WithRelocationMap(relocationMap relocation.ImageRelocationMap) FixupOption
- type ManifestOption
- type ProgressSnapshot
Examples ¶
Constants ¶
const ( // FixupEventTypeCopyImageStart is raised when the Fixup logic starts copying an // image FixupEventTypeCopyImageStart = FixupEventType("CopyImageStart") // FixupEventTypeCopyImageEnd is raised when the Fixup logic stops copying an // image. Error might be populated FixupEventTypeCopyImageEnd = FixupEventType("CopyImageEnd") // FixupEventTypeProgress is raised when Fixup logic reports progression FixupEventTypeProgress = FixupEventType("Progress") )
Variables ¶
This section is empty.
Functions ¶
func CreateResolver ¶
func CreateResolver(cfg *configfile.ConfigFile, plainHTTPRegistries ...string) remotes.Resolver
CreateResolver creates a docker registry resolver, using the local docker CLI credentials
func FixupBundle ¶
func FixupBundle(ctx context.Context, b *bundle.Bundle, ref reference.Named, resolver remotes.Resolver, opts ...FixupOption) (relocation.ImageRelocationMap, error)
FixupBundle checks that all the references are present in the referenced repository, otherwise it will mount all the manifests to that repository. The bundle is then patched with the new digested references.
func Pull ¶
func Pull(ctx context.Context, ref reference.Named, resolver remotes.Resolver) (*bundle.Bundle, relocation.ImageRelocationMap, error)
Pull pulls a bundle from an OCI Image Index manifest
Example ¶
nolint: lll
// Use remotes.CreateResolver for creating your remotes.Resolver resolver := createExampleResolver() ref, err := reference.ParseNamed("my.registry/namespace/my-app:my-tag") if err != nil { panic(err) } // Pull the CNAB, get the bundle and the associated relocation map resultBundle, relocationMap, err := Pull(context.Background(), ref, resolver) if err != nil { panic(err) } resultBundle.WriteTo(os.Stdout) //nolint:errcheck buf, err := json.Marshal(relocationMap) if err != nil { panic(err) } fmt.Printf("\n") fmt.Println(string(buf))
Output: {"actions":{"action-1":{"modifies":true}},"credentials":{"cred-1":{"env":"env-var","path":"/some/path"}},"custom":{"my-key":"my-value"},"definitions":{"output1Type":{"type":"string"},"param1Type":{"default":"hello","enum":["value1",true,1],"type":["string","boolean","number"]}},"description":"description","images":{"another-image":{"contentDigest":"sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0342","description":"","image":"my.registry/namespace/another-image","imageType":"oci","mediaType":"application/vnd.oci.image.manifest.v1+json","size":507},"image-1":{"contentDigest":"sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0341","description":"","image":"my.registry/namespace/image-1","imageType":"oci","mediaType":"application/vnd.oci.image.manifest.v1+json","size":507}},"invocationImages":[{"contentDigest":"sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0343","image":"my.registry/namespace/my-app-invoc","imageType":"docker","mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":506}],"keywords":["keyword1","keyword2"],"maintainers":[{"email":"docker@docker.com","name":"docker","url":"docker.com"}],"name":"my-app","outputs":{"output1":{"applyTo":["install"],"definition":"output1Type","description":"magic","path":"/cnab/app/outputs/magic"}},"parameters":{"param1":{"definition":"param1Type","destination":{"env":"env_var","path":"/some/path"}}},"schemaVersion":"v1.0.0","version":"0.1.0"} {"my.registry/namespace/image-1":"my.registry/namespace/my-app@sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0341","my.registry/namespace/my-app-invoc":"my.registry/namespace/my-app@sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0341"}
func Push ¶
func Push(ctx context.Context, b *bundle.Bundle, relocationMap relocation.ImageRelocationMap, ref reference.Named, resolver remotes.Resolver, allowFallbacks bool, options ...ManifestOption) (ocischemav1.Descriptor, error)
Push pushes a bundle as an OCI Image Index manifest
Example ¶
resolver := createExampleResolver() b := createExampleBundle() ref, err := reference.ParseNamed("my.registry/namespace/my-app:my-tag") if err != nil { panic(err) } // Push the bundle here descriptor, err := Push(context.Background(), b, tests.MakeRelocationMap(), ref, resolver, true) if err != nil { panic(err) } bytes, err := json.MarshalIndent(descriptor, "", " ") if err != nil { panic(err) } fmt.Printf("%s", string(bytes))
Output: { "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:4cfae04045c6f0fd14330ab86dea9694fb19ce9602ba2da0af8c826fc0053631", "size": 1360 }
Types ¶
type DescriptorProgressSnapshot ¶
type DescriptorProgressSnapshot struct { ocischemav1.Descriptor Done bool Action string Error error Children []DescriptorProgressSnapshot }
DescriptorProgressSnapshot describes the current progress of a descriptor
type FixupEvent ¶
type FixupEvent struct { SourceImage string DestinationRef reference.Named EventType FixupEventType Message string Error error Progress ProgressSnapshot }
FixupEvent is an event that is raised by the Fixup Logic
type FixupEventType ¶
type FixupEventType string
FixupEventType is the the type of event raised by the Fixup logic
type FixupOption ¶
type FixupOption func(*fixupConfig) error
FixupOption is a helper for configuring a FixupBundle
func WithAutoBundleUpdate ¶
func WithAutoBundleUpdate() FixupOption
WithAutoBundleUpdate updates the bundle with content digests and size provided by the registry
func WithComponentImagePlatforms ¶
func WithComponentImagePlatforms(supportedPlatforms []string) FixupOption
WithComponentImagePlatforms use filters platforms for an invocation image
func WithEventCallback ¶
func WithEventCallback(callback func(FixupEvent)) FixupOption
WithEventCallback specifies a callback to execute for each Fixup event
func WithInvocationImagePlatforms ¶
func WithInvocationImagePlatforms(supportedPlatforms []string) FixupOption
WithInvocationImagePlatforms use filters platforms for an invocation image
func WithParallelism ¶
func WithParallelism(maxConcurrentJobs int, jobsBufferLength int) FixupOption
WithParallelism provides a way to change the max concurrent jobs and the max number of jobs queued up
func WithPushImages ¶
func WithPushImages(imageClient internal.ImageClient, out io.Writer) FixupOption
WithPushImages authorizes the fixup command to push missing images. By default the fixup will look at images defined in the bundle. Existing images in the target registry or accessible from an other registry will be copied or mounted under the target tag. But local only images (for example after a local build of components of the bundle) must be pushed. This option will allow to push images that are only available in the docker daemon image store to the defined target.
func WithRelocationMap ¶
func WithRelocationMap(relocationMap relocation.ImageRelocationMap) FixupOption
WithRelocationMap stores a previously generated relocation map. This map will be used to copy or mount images based on local images but already pushed on a registry. This way if a bundle is pulled on a machine that doesn't contain the images, when the bundle is pushed and images are not found the fixup will try to resolve the corresponding images from the relocation map.
type ManifestOption ¶
type ManifestOption func(*ocischemav1.Index) error
ManifestOption is a callback used to customize a manifest before pushing it
type ProgressSnapshot ¶
type ProgressSnapshot struct {
Roots []DescriptorProgressSnapshot
}
ProgressSnapshot describes the current progress of a Fixup operation