registry

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package registry contains functions to detect the registry scheme

Index

Constants

View Source
const (
	// HTTP protocol for registry
	HTTP = "http"
	// HTTPS protol for registry
	HTTPS = "https"
)

Variables

This section is empty.

Functions

func DefaultDetectImageRegistryScheme

func DefaultDetectImageRegistryScheme(ctx context.Context, registryHost string, registryClient *http.Client, insecure bool) (string, error)

DefaultDetectImageRegistryScheme detect image registry scheme using default registry pinger

func PushEmptyImage added in v0.9.0

func PushEmptyImage(ctx context.Context, uri artifactv1.URI) error

PushEmptyImage an empty image will be created and pushed. The function will read the credentials from the context. If the credentials are empty, only the credentials will not be used for push.

func TryProtocolsWithRegistryURL

func TryProtocolsWithRegistryURL(ctx context.Context, registry string, allowInsecure bool, action func(registryURL url.URL) error) (*url.URL, error)

TryProtocolsWithRegistryURL runs given action with different protocols until no error is returned. The https protocol is the first attempt. If it fails and allowInsecure is true, http will be the next. Obtained errors will be concatenated and returned.

Types

type AuthOption

type AuthOption func(*resty.Client) *resty.Client

AuthOption auth option for registry client

func WithAuthScheme

func WithAuthScheme(scheme string) AuthOption

WithAuthScheme set auth scheme for registry client

func WithAuthToken

func WithAuthToken(token string) AuthOption

WithAuthToken set auth token for registry client

func WithBasicAuth

func WithBasicAuth(username, password string) AuthOption

WithBasicAuth set basic auth for registry client

type DefaultRegistryPinger

type DefaultRegistryPinger struct {
	Client   *http.Client
	Insecure bool
}

DefaultRegistryPinger implements RegistryPinger.

func (*DefaultRegistryPinger) Ping

func (drp *DefaultRegistryPinger) Ping(ctx context.Context, registry string) (*url.URL, error)

Ping verifies that the integrated registry is ready, determines its transport protocol and returns its url or error.

type DefaultRegistrySchemeDetection

type DefaultRegistrySchemeDetection struct {
	// Client is the resty client
	Client *resty.Client

	// Server should be accessed without verifying the TLS certificate.
	Insecure bool

	// Cache indicates whether to cache the scheme
	Cache bool
	// contains filtered or unexported fields
}

DefaultRegistrySchemeDetection default scheme detection

func NewDefaultRegistrySchemeDetection

func NewDefaultRegistrySchemeDetection(client *resty.Client, insecure, cache bool) *DefaultRegistrySchemeDetection

NewDefaultRegistrySchemeDetection create default registry scheme detection

func (*DefaultRegistrySchemeDetection) DetectScheme

func (d *DefaultRegistrySchemeDetection) DetectScheme(ctx context.Context, registry string, auths ...AuthOption) (string, error)

DetectScheme detect registry scheme

func (*DefaultRegistrySchemeDetection) DetectSchemeWithDefault

func (d *DefaultRegistrySchemeDetection) DetectSchemeWithDefault(ctx context.Context, registry, defaultScheme string, auths ...AuthOption) string

DetectSchemeWithDefault detect registry scheme, if detect failed, return default scheme

type DryRunRegistryPinger

type DryRunRegistryPinger struct {
}

DryRunRegistryPinger implements RegistryPinger.

func (*DryRunRegistryPinger) Ping

func (*DryRunRegistryPinger) Ping(registry string) (*url.URL, error)

Ping implements Ping method.

type ManifestClient

type ManifestClient struct {
	// contains filtered or unexported fields
}

func NewManifestClient

func NewManifestClient(options ...regclient.Opt) *ManifestClient

func (*ManifestClient) GetAnnotations

func (c *ManifestClient) GetAnnotations(ctx context.Context, reference string) (map[string]string, error)

GetAnnotations get annotations from a reference image

func (*ManifestClient) Insecure

func (c *ManifestClient) Insecure(value bool) *ManifestClient

Insecure access registry without verifying the TLS certificate

func (*ManifestClient) PutEmptyIndex

func (c *ManifestClient) PutEmptyIndex(ctx context.Context, reference string, annotations map[string]string) error

PutEmptyIndex create an empty manifest list with annotations

func (*ManifestClient) SetAnnotation

func (c *ManifestClient) SetAnnotation(ctx context.Context, reference string, annotations map[string]string) error

SetAnnotation append annotation to a reference image annotation key will be deleted with empty value

type RegistryPinger

type RegistryPinger interface {
	// Ping performs a health check against registry. It returns registry url qualified with schema unless an
	// error occurs.
	Ping(ctx context.Context, registry string) (*url.URL, error)
}

RegistryPinger performs a health check against a registry.

type RegistrySchemeDetection

type RegistrySchemeDetection interface {
	// DetectScheme detect registry scheme
	DetectScheme(ctx context.Context, registry string, auths ...AuthOption) (string, error)

	// DetectSchemeWithDefault detect registry scheme, if detect failed, return default scheme
	DetectSchemeWithDefault(ctx context.Context, registry, defaultScheme string, auths ...AuthOption) string
}

RegistrySchemeDetection detect registry scheme

type RegistrySchemeDetectionBySecret

type RegistrySchemeDetectionBySecret struct {
	*DefaultRegistrySchemeDetection
	// contains filtered or unexported fields
}

RegistrySchemeDetectionBySecret detect registry scheme by secret

func NewRegistrySchemeDetectionBySecret

func NewRegistrySchemeDetectionBySecret(client *resty.Client, insecure, cache bool) *RegistrySchemeDetectionBySecret

NewRegistrySchemeDetectionBySecret create a new RegistrySchemeDetectionBySecret

func (*RegistrySchemeDetectionBySecret) DetectScheme

func (d *RegistrySchemeDetectionBySecret) DetectScheme(ctx context.Context, registry string, auths ...AuthOption) (string, error)

DetectScheme detect registry scheme If the secret exists, the parameter of username and password will be ignored. These parameters are reserved only to satisfy the interface `RegistrySchemeDetection`

func (*RegistrySchemeDetectionBySecret) DetectSchemeWithDefault

func (d *RegistrySchemeDetectionBySecret) DetectSchemeWithDefault(ctx context.Context, registry, defaultScheme string, auths ...AuthOption) string

DetectSchemeWithDefault detect registry scheme, if detect failed, return default scheme

func (*RegistrySchemeDetectionBySecret) WithClient

WithClient set client

func (*RegistrySchemeDetectionBySecret) WithSecretRef

WithSecretRef set secret reference

Jump to

Keyboard shortcuts

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