Documentation ¶
Index ¶
- func DefaultOptions() []crane.Option
- func GetAuthFromCredentials(credentials string) (authn.Authenticator, error)
- func IsCosignArtifact(tag string) bool
- func ParseArtifactURL(ociURL string) (string, error)
- func ParseRepositoryURL(ociURL string) (string, error)
- func WithRetryBackOff(backoff remote.Backoff) crane.Option
- func WithRetryTransport(ctx context.Context, ref name.Reference, auth authn.Authenticator, ...) (crane.Option, error)
- type Client
- func (c *Client) Build(artifactPath, sourceDir string, ignorePaths []string) (err error)
- func (c *Client) Delete(ctx context.Context, url string) error
- func (c *Client) Diff(ctx context.Context, url, dir string, ignorePaths []string) error
- func (c *Client) GetOptions() []crane.Option
- func (c *Client) List(ctx context.Context, url string, opts ListOptions) ([]Metadata, error)
- func (c *Client) LoginWithCredentials(credentials string) error
- func (c *Client) LoginWithProvider(ctx context.Context, url string, provider oci.Provider) error
- func (c *Client) Pull(ctx context.Context, url, outPath string, opts ...PullOption) (*Metadata, error)
- func (c *Client) Push(ctx context.Context, url, sourcePath string, opts ...PushOption) (string, error)
- func (c *Client) Tag(ctx context.Context, url, tag string) (string, error)
- type LayerType
- type ListOptions
- type Metadata
- type PullOption
- type PullOptions
- type PushOption
- type PushOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOptions ¶
DefaultOptions returns an empty list of client options.
func GetAuthFromCredentials ¶
func GetAuthFromCredentials(credentials string) (authn.Authenticator, error)
GetAuthFromCredentials returns an authn.Authenticator for the static credentials, accepts a single token or a user:password format.
func IsCosignArtifact ¶
IsCosignArtifact will return true if the tag has one of the following suffices: ".att", ".sbom", or ".sig". These are the suffices used by cosign to store the attestations, SBOMs, and signatures respectively.
func ParseArtifactURL ¶
ParseArtifactURL validates the OCI URL and returns the address of the artifact.
func ParseRepositoryURL ¶
ParseRepositoryURL validates the OCI URL and returns the address of the artifact repository.
func WithRetryBackOff ¶
WithRetryBackOff returns a function for setting the given backoff on crane.Option.
func WithRetryTransport ¶
func WithRetryTransport(ctx context.Context, ref name.Reference, auth authn.Authenticator, backoff remote.Backoff, scopes []string) (crane.Option, error)
WithRetryTransport returns a crane.Option for setting transport that uses the backoff for retries
Most parts(including the functions below) are copied from https://github.com/google/go-containerregistry/blob/v0.14.0/pkg/v1/remote/options.go#L152 so we have the same transport used in the library but with a different retry backoff.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client holds the options for accessing remote OCI registries.
func (*Client) Build ¶
Build archives the given directory as a tarball to the given local path. While archiving, any environment specific data (for example, the user and group name) is stripped from file headers.
func (*Client) Delete ¶
Delete deletes a particular image from an OCI repository If the url has no tag, the latest image is deleted
func (*Client) Diff ¶
Diff compares the files included in an OCI image with the local files in the given path and returns an error if the contents is different
func (*Client) GetOptions ¶
GetOptions returns the list of crane.Option used by this Client.
func (*Client) LoginWithCredentials ¶
LoginWithCredentials configures the client with static credentials, accepts a single token or a user:password format.
func (*Client) LoginWithProvider ¶
LoginWithProvider configures the client to log in to the specified provider
func (*Client) Pull ¶
func (c *Client) Pull(ctx context.Context, url, outPath string, opts ...PullOption) (*Metadata, error)
Pull downloads an artifact from an OCI repository and extracts the content. It untar or copies the content to the given outPath depending on the layerType. If no layer type is given, it tries to determine the right type by checking compressed content of the layer.
type LayerType ¶
type LayerType string
LayerType is an enumeration of the supported layer types when pushing an image.
type ListOptions ¶
type ListOptions struct { // SemverFilter contains semver for filtering tags. SemverFilter string // RegexFilter contains a regex that tags will be filtered by. RegexFilter string // IncludeCosignArtifacts can be used to include cosign attestation, // signature and SBOM tags in the list, as these are excluded by default. IncludeCosignArtifacts bool }
ListOptions contains options for listing tags from an OCI repository.
type Metadata ¶
type Metadata struct { Created string `json:"created,omitempty"` Source string `json:"source_url,omitempty"` Revision string `json:"source_revision,omitempty"` Digest string `json:"digest"` URL string `json:"url"` Annotations map[string]string `json:"annotations,omitempty"` }
Metadata holds the upstream information about on artifact's source. https://github.com/opencontainers/image-spec/blob/main/annotations.md
func MetadataFromAnnotations ¶
MetadataFromAnnotations parses the OpenContainers annotations and returns a Metadata object.
func (*Metadata) ToAnnotations ¶
ToAnnotations returns the OpenContainers annotations map.
type PullOption ¶
type PullOption func(o *PullOptions)
PullOption is a function for configuring PullOptions.
func WithPullLayerIndex ¶
func WithPullLayerIndex(i int) PullOption
WithPullLayerIndex set the index of the layer to be pulled.
func WithPullLayerType ¶
func WithPullLayerType(l LayerType) PullOption
WithPullLayerType sets the layer type of the layer that is being pulled.
type PullOptions ¶
type PullOptions struct {
// contains filtered or unexported fields
}
PullOptions contains options for pulling a layer.
type PushOption ¶
type PushOption func(o *PushOptions)
PushOption is a function for configuring PushOptions.
func WithPushIgnorePaths ¶
func WithPushIgnorePaths(paths ...string) PushOption
WithPushIgnorePaths configures ignore paths for PushOptions
func WithPushLayerType ¶
func WithPushLayerType(l LayerType) PushOption
WithPushLayerType set the layer type that will be used when creating the image layer.
func WithPushMediaTypeExt ¶
func WithPushMediaTypeExt(extension string) PushOption
WithPushMediaTypeExt configures the media type extension for the image layer. This is only used when the layer type is `LayerTypeStatic`. The final media type will be prefixed with `application/vnd.cncf.flux.content.v1`
func WithPushMetadata ¶
func WithPushMetadata(meta Metadata) PushOption
WithPushMetadata configures Metadata that will be used for image annotations.
type PushOptions ¶
type PushOptions struct {
// contains filtered or unexported fields
}
PushOptions are options for configuring the Push operation.