Documentation
¶
Index ¶
- Constants
- Variables
- type BlobClient
- type ConfigHost
- type ImageClient
- type ImageOpts
- type ManifestClient
- type Opt
- func WithBlobSize(chunk, max int64) Opt
- func WithCertDir(path string) Opt
- func WithConfigHost(configHost ConfigHost) Opt
- func WithConfigHosts(configHosts []ConfigHost) Opt
- func WithDockerCerts() Opt
- func WithDockerCreds() Opt
- func WithLog(log *logrus.Logger) Opt
- func WithRetryDelay(delayInit, delayMax time.Duration) Opt
- func WithRetryLimit(retryLimit int) Opt
- func WithUserAgent(ua string) Opt
- type RegClient
- type RepoClient
- type RepoDockerList
- type RepoList
- type RepoOpts
- type TLSConf
- type TagClient
- type TagDockerList
- type TagList
- type TagOpts
Constants ¶
const ( // MediaTypeDocker1Manifest deprecated media type for docker schema1 manifests MediaTypeDocker1Manifest = "application/vnd.docker.distribution.manifest.v1+json" // MediaTypeDocker1ManifestSigned is a deprecated schema1 manifest with jws signing MediaTypeDocker1ManifestSigned = "application/vnd.docker.distribution.manifest.v1+prettyjws" // MediaTypeDocker2Manifest is the media type when pulling manifests from a v2 registry MediaTypeDocker2Manifest = "application/vnd.docker.distribution.manifest.v2+json" // MediaTypeDocker2ManifestList is the media type when pulling a manifest list from a v2 registry MediaTypeDocker2ManifestList = "application/vnd.docker.distribution.manifest.list.v2+json" // MediaTypeDocker2ImageConfig is for the configuration json object media type MediaTypeDocker2ImageConfig = "application/vnd.docker.container.image.v1+json" // MediaTypeOCI1Manifest OCI v1 manifest media type MediaTypeOCI1Manifest = "application/vnd.oci.image.manifest.v1+json" // MediaTypeOCI1ManifestList OCI v1 manifest list media type MediaTypeOCI1ManifestList = "application/vnd.oci.image.index.v1+json" // MediaTypeOCI1ImageConfig OCI v1 configuration json object media type MediaTypeOCI1ImageConfig = "application/vnd.oci.image.config.v1+json" // MediaTypeDocker2Layer is the default compressed layer for docker schema2 MediaTypeDocker2Layer = "application/vnd.docker.image.rootfs.diff.tar.gzip" // MediaTypeOCI1Layer is the uncompressed layer for OCIv1 MediaTypeOCI1Layer = "application/vnd.oci.image.layer.v1.tar" // MediaTypeOCI1LayerGzip is the gzip compressed layer for OCI v1 MediaTypeOCI1LayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip" // MediaTypeBuildkitCacheConfig is used by buildkit cache images MediaTypeBuildkitCacheConfig = "application/vnd.buildkit.cacheconfig.v0" )
const ( // DefaultBlobChunk 1M chunks, this is allocated in a memory buffer DefaultBlobChunk = 1024 * 1024 // DefaultBlobMax is disabled to support registries without chunked upload support DefaultBlobMax = -1 // DefaultRetryLimit sets how many retry attempts are made for non-fatal errors DefaultRetryLimit = 3 // DefaultUserAgent sets the header on http requests DefaultUserAgent = "regclient/regclient" // DockerCertDir default location for docker certs DockerCertDir = "/etc/docker/certs.d" // DockerRegistry is the name resolved in docker images on Hub DockerRegistry = "docker.io" // DockerRegistryAuth is the name provided in docker's config for Hub DockerRegistryAuth = "https://index.docker.io/v1/" // DockerRegistryDNS is the host to connect to for Hub DockerRegistryDNS = "registry-1.docker.io" )
Variables ¶
var ( // ErrAPINotFound if an api is not available for the host ErrAPINotFound = errors.New("API not found") // ErrCanceled if the context was canceled ErrCanceled = errors.New("Context was canceled") // ErrHttpStatus if the http status code was unexpected ErrHttpStatus = errors.New("Unexpected http status code") // ErrMissingDigest returned when image reference does not include a digest ErrMissingDigest = errors.New("Digest missing from image reference") // ErrMissingLocation returned when the location header is missing ErrMissingLocation = errors.New("Location header missing") // ErrMissingName returned when name missing for host ErrMissingName = errors.New("Name missing") // ErrMissingTag returned when image reference does not include a tag ErrMissingTag = errors.New("Tag missing from image reference") // ErrMissingTagOrDigest returned when image reference does not include a tag or digest ErrMissingTagOrDigest = errors.New("Tag or Digest missing from image reference") // ErrMountReturnedLocation when a blob mount fails but a location header is received ErrMountReturnedLocation = errors.New("Blob mount returned a location to upload") // ErrNotFound isn't there, search for your value elsewhere ErrNotFound = errors.New("Not found") // ErrNotImplemented returned when method has not been implemented yet ErrNotImplemented = errors.New("Not implemented") // ErrParsingFailed when a string cannot be parsed ErrParsingFailed = errors.New("Parsing failed") // ErrRateLimit when requests exceed server rate limit ErrRateLimit = errors.New("Rate limit exceeded") ErrUnavailable = errors.New("Unavailable") ErrUnauthorized = errors.New("Unauthorized") // ErrUnsupportedAPI happens when an API is not supported on a registry ErrUnsupportedAPI = errors.New("Unsupported API") // ErrUnsupportedConfigVersion happens when config file version is greater than this command supports ErrUnsupportedConfigVersion = errors.New("Unsupported config version") // ErrUnsupportedMediaType returned when media type is unknown or unsupported ErrUnsupportedMediaType = errors.New("Unsupported media type") )
var TemplateFuncs = gotemplate.FuncMap{
"printPretty": printPretty,
}
TemplateFuncs provides additional functions for handling regclient types in templates
var (
// VCSRef is injected from a build flag, used to version the UserAgent header
VCSRef = "unknown"
)
Functions ¶
This section is empty.
Types ¶
type BlobClient ¶ added in v0.3.0
type BlobClient interface {
BlobCopy(ctx context.Context, refSrc types.Ref, refTgt types.Ref, d digest.Digest) error
BlobGet(ctx context.Context, ref types.Ref, d digest.Digest, accepts []string) (blob.Reader, error)
BlobGetOCIConfig(ctx context.Context, ref types.Ref, d digest.Digest) (blob.OCIConfig, error)
BlobHead(ctx context.Context, ref types.Ref, d digest.Digest) (blob.Reader, error)
BlobMount(ctx context.Context, refSrc types.Ref, refTgt types.Ref, d digest.Digest) error
BlobPut(ctx context.Context, ref types.Ref, d digest.Digest, rdr io.Reader, ct string, cl int64) (digest.Digest, int64, error)
}
BlobClient provides registry client requests to Blobs
type ConfigHost ¶
type ConfigHost struct {
Name string `json:"-"`
Scheme string `json:"scheme,omitempty"` // TODO: deprecate, delete
TLS TLSConf `json:"tls,omitempty"`
RegCert string `json:"regcert,omitempty"`
ClientCert string `json:"clientcert,omitempty"`
ClientKey string `json:"clientkey,omitempty"`
DNS []string `json:"dns,omitempty"` // TODO: remove slice, single string, or remove entirely?
Hostname string `json:"hostname,omitempty"` // replaces DNS array with single string
User string `json:"user,omitempty"`
Pass string `json:"pass,omitempty"`
Token string `json:"token,omitempty"`
PathPrefix string `json:"pathPrefix,omitempty"` // used for mirrors defined within a repository namespace
Mirrors []string `json:"mirrors,omitempty"` // list of other ConfigHost Names to use as mirrors
Priority uint `json:"priority,omitempty"` // priority when sorting mirrors, higher priority attempted first
API string `json:"api,omitempty"` // experimental: registry API to use
APIOpts map[string]string `json:"apiOpts,omitempty"` // options for APIs
BlobChunk int64 `json:"blobChunk,omitempty"` // size of each blob chunk
BlobMax int64 `json:"blobMax,omitempty"` // threshold to switch to chunked upload, -1 to disable, 0 for regclient.blobMaxPut
}
ConfigHost struct contains host specific settings
func ConfigHostNew ¶
func ConfigHostNew() *ConfigHost
ConfigHostNew creates a default ConfigHost entry
func ConfigHostNewName ¶ added in v0.3.0
func ConfigHostNewName(host string) *ConfigHost
ConfigHostNewName creates a default ConfigHost with a hostname
type ImageClient ¶ added in v0.3.0
type ImageClient interface {
ImageCopy(ctx context.Context, refSrc types.Ref, refTgt types.Ref, opts ...ImageOpts) error
ImageExport(ctx context.Context, ref types.Ref, outStream io.Writer) error
ImageImport(ctx context.Context, ref types.Ref, rs io.ReadSeeker) error
}
ImageClient provides registry client requests to images
type ImageOpts ¶ added in v0.3.10
type ImageOpts func(*imageOpt)
func ImageWithDigestTags ¶ added in v0.3.10
func ImageWithDigestTags() ImageOpts
ImageWithDigestTags looks for "sha-<digest>.*" tags in the repo to copy with any manifest. These are used by some artifact systems like sigstore/cosign.
func ImageWithForceRecursive ¶ added in v0.3.10
func ImageWithForceRecursive() ImageOpts
ImageWithForceRecursive attemtps to copy every manifest and blob even if parent manifests already exist.
func ImageWithPlatforms ¶ added in v0.3.10
ImageWithPlatforms only copies specific platforms from a manifest list. This will result in a failure on many registries that validate manifests. Use the empty string to indicate images without a platform definition should be copied.
type ManifestClient ¶ added in v0.3.0
type ManifestClient interface {
ManifestDelete(ctx context.Context, ref types.Ref) error
ManifestGet(ctx context.Context, ref types.Ref) (manifest.Manifest, error)
ManifestHead(ctx context.Context, ref types.Ref) (manifest.Manifest, error)
ManifestPut(ctx context.Context, ref types.Ref, m manifest.Manifest) error
}
ManifestClient provides registry client requests to manifests
type Opt ¶
type Opt func(*regClient)
Opt functions are used to configure NewRegClient
func WithBlobSize ¶ added in v0.3.6
WithBlobSize overrides default blob sizes
func WithCertDir ¶ added in v0.3.0
WithCertDir adds a path of certificates to trust similar to Docker's /etc/docker/certs.d
func WithConfigHost ¶ added in v0.1.0
func WithConfigHost(configHost ConfigHost) Opt
WithConfigHost adds config host settings
func WithConfigHosts ¶ added in v0.1.0
func WithConfigHosts(configHosts []ConfigHost) Opt
WithConfigHosts adds a list of config host settings
func WithDockerCerts ¶
func WithDockerCerts() Opt
WithDockerCerts adds certificates trusted by docker in /etc/docker/certs.d
func WithDockerCreds ¶
func WithDockerCreds() Opt
WithDockerCreds adds configuration from users docker config with registry logins This changes the default value from the config file, and should be added after the config file is loaded
func WithRetryDelay ¶ added in v0.3.6
WithRetryDelay specifies the time permitted for retry delays
func WithRetryLimit ¶ added in v0.3.0
WithRetryLimit specifies the number of retries for non-fatal errors
func WithUserAgent ¶ added in v0.3.0
WithUserAgent specifies the User-Agent http header
type RegClient ¶
type RegClient interface {
RepoClient
TagClient
ManifestClient
ImageClient
BlobClient
}
RegClient provides an interfaces to working with registries
type RepoClient ¶ added in v0.3.0
type RepoClient interface {
RepoList(ctx context.Context, hostname string) (RepoList, error)
RepoListWithOpts(ctx context.Context, hostname string, opts RepoOpts) (RepoList, error)
}
RepoClient provides registry client requests to repositories
type RepoDockerList ¶ added in v0.3.0
type RepoDockerList struct {
Repositories []string `json:"repositories"`
}
RepoDockerList is a list of repositories from the _catalog API
func (RepoDockerList) GetRepos ¶ added in v0.3.0
func (rl RepoDockerList) GetRepos() ([]string, error)
GetRepos returns the repositories
func (RepoDockerList) MarshalPretty ¶ added in v0.3.0
func (rl RepoDockerList) MarshalPretty() ([]byte, error)
MarshalPretty is used for printPretty template formatting
type RepoList ¶ added in v0.3.0
type RepoList interface {
GetOrig() interface{}
MarshalJSON() ([]byte, error)
RawBody() ([]byte, error)
RawHeaders() (http.Header, error)
GetRepos() ([]string, error)
}
RepoList interface is used for listing tags
type TLSConf ¶ added in v0.1.0
type TLSConf int
TLSConf specifies whether TLS is enabled for a host
func (TLSConf) MarshalJSON ¶ added in v0.1.0
MarshalJSON converts to a json string using MarshalText
func (TLSConf) MarshalText ¶ added in v0.1.0
MarshalText converts TLSConf to a string
func (*TLSConf) UnmarshalJSON ¶ added in v0.1.0
UnmarshalJSON converts TLSConf from a json string
func (*TLSConf) UnmarshalText ¶ added in v0.1.0
UnmarshalText converts TLSConf from a string
type TagClient ¶ added in v0.3.0
type TagClient interface {
TagDelete(ctx context.Context, ref types.Ref) error
TagList(ctx context.Context, ref types.Ref) (TagList, error)
TagListWithOpts(ctx context.Context, ref types.Ref, opts TagOpts) (TagList, error)
}
TagClient wraps calls to tag list and delete
type TagDockerList ¶ added in v0.3.0
TagDockerList is returned from registry/2.0 API's
func (TagDockerList) GetTags ¶ added in v0.3.0
func (tl TagDockerList) GetTags() ([]string, error)
GetTags returns the tags from a list
func (TagDockerList) MarshalPretty ¶ added in v0.3.0
func (tl TagDockerList) MarshalPretty() ([]byte, error)
MarshalPretty is used for printPretty template formatting