Documentation ¶
Overview ¶
Package registry contains functions to detect the registry scheme
Index ¶
- Constants
- func DefaultDetectImageRegistryScheme(ctx context.Context, registryHost string, registryClient *http.Client, ...) (string, error)
- func PushEmptyImage(ctx context.Context, uri artifactv1.URI) error
- func TryProtocolsWithRegistryURL(ctx context.Context, registry string, allowInsecure bool, ...) (*url.URL, error)
- type AuthOption
- type DefaultRegistryPinger
- type DefaultRegistrySchemeDetection
- type DryRunRegistryPinger
- type ManifestClient
- func (c *ManifestClient) GetAnnotations(ctx context.Context, reference string) (map[string]string, error)
- func (c *ManifestClient) Insecure(value bool) *ManifestClient
- func (c *ManifestClient) PutEmptyIndex(ctx context.Context, reference string, annotations map[string]string) error
- func (c *ManifestClient) SetAnnotation(ctx context.Context, reference string, annotations map[string]string) error
- type RegistryPinger
- type RegistrySchemeDetection
- type RegistrySchemeDetectionBySecret
- func (d *RegistrySchemeDetectionBySecret) DetectScheme(ctx context.Context, registry string, auths ...AuthOption) (string, error)
- func (d *RegistrySchemeDetectionBySecret) DetectSchemeWithDefault(ctx context.Context, registry, defaultScheme string, auths ...AuthOption) string
- func (d *RegistrySchemeDetectionBySecret) WithClient(clt client.Client) *RegistrySchemeDetectionBySecret
- func (d *RegistrySchemeDetectionBySecret) WithSecretRef(secretRef *corev1.ObjectReference) *RegistrySchemeDetectionBySecret
Constants ¶
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 ¶
DefaultRegistryPinger implements RegistryPinger.
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.
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 ¶
func (d *RegistrySchemeDetectionBySecret) WithClient(clt client.Client) *RegistrySchemeDetectionBySecret
WithClient set client
func (*RegistrySchemeDetectionBySecret) WithSecretRef ¶
func (d *RegistrySchemeDetectionBySecret) WithSecretRef(secretRef *corev1.ObjectReference) *RegistrySchemeDetectionBySecret
WithSecretRef set secret reference