remotes

package
v0.0.0-...-0bf8355 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Examples

Constants

View Source
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) 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, 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 and get the bundle
resultBundle, err := Pull(context.Background(), ref, resolver)
if err != nil {
	panic(err)
}

resultBundle.WriteTo(os.Stdout)
Output:

{"actions":{"action-1":{"modifies":true}},"credentials":{"cred-1":{"env":"env-var","path":"/some/path"}},"definitions":{"param1Type":{"default":"hello","enum":["value1",true,1],"type":["string","boolean","number"]}},"description":"description","images":{"image-1":{"description":"","image":"my.registry/namespace/my-app@sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0341","imageType":"oci","mediaType":"application/vnd.oci.image.manifest.v1+json","size":507}},"invocationImages":[{"image":"my.registry/namespace/my-app@sha256:d59a1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0341","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","parameters":{"fields":{"param1":{"definition":"param1Type","destination":{"env":"env_var","path":"/some/path"}}}},"schemaVersion":"v1.0.0-WD","version":"0.1.0"}

func Push

func Push(ctx context.Context, b *bundle.Bundle, 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, 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:b4ec5b6008592c0badea020ac7402797f13120fc11d7fe6c0f91b77a439d9d4c",
  "size": 1363
}

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 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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL