udistribution

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 52 Imported by: 3

README

Bits from container/image/docker modified for use with udistribution.

Modifications:

  • Transport name renamed from docker to udistribution-docker
  • Modified docker_client.go/makeRequestToResolvedURLOnce to use response recorder against distribution/distribution Registry App's ServeHTTP method instead of sending requests to a listening HTTP server.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrV1NotSupported is returned when we're trying to talk to a
	// docker V1 registry.
	ErrV1NotSupported = errors.New("can't talk to a V1 container registry")
	// ErrTooManyRequests is returned when the status code returned is 429
	ErrTooManyRequests = errors.New("too many requests to registry")
)

Functions

func CheckAuth

func CheckAuth(ctx context.Context, sys *types.SystemContext, username, password, registry string) error

CheckAuth validates the credentials by attempting to log into the registry returns an error if an error occurred while making the http request or the status code received was 401

func GetDigest

func GetDigest(ctx context.Context, sys *types.SystemContext, ref types.ImageReference) (digest.Digest, error)

GetDigest returns the image's digest Use this to optimize and avoid use of an ImageSource based on the returned digest; if you are going to use an ImageSource anyway, it’s more efficient to create it first and compute the digest from the value returned by GetManifest. NOTE: Implemented to avoid Docker Hub API limits, and mirror configuration may be ignored (but may be implemented in the future)

func GetRef

for test

func GetRepositoryTags

func GetRepositoryTags(ctx context.Context, sys *types.SystemContext, ref types.ImageReference) ([]string, error)

GetRepositoryTags list all tags available in the repository. The tag provided inside the ImageReference will be ignored.

func NewReference

NewReference returns a Docker reference for a named reference. The reference must satisfy !reference.IsNameOnly().

func ParseReference

func ParseReference(refString string, ut *UdistributionTransport) (types.ImageReference, error)

ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an Docker ImageReference.

func SignatureStorageBaseURL

func SignatureStorageBaseURL(sys *types.SystemContext, ref types.ImageReference, write bool) (*url.URL, error)

SignatureStorageBaseURL reads configuration to find an appropriate signature storage URL for ref, for write access if “write”. the usage of the BaseURL is defined under docker/distribution registries—separate storage of docs/signature-protocols.md Warning: This function only exposes configuration in registries.d; just because this function returns an URL does not mean that the URL will be used by c/image/docker (e.g. if the registry natively supports X-R-S-S).

Types

type ErrUnauthorizedForCredentials

type ErrUnauthorizedForCredentials struct {
	Err error
}

ErrUnauthorizedForCredentials is returned when the status code returned is 401

func (ErrUnauthorizedForCredentials) Error

type Image

type Image struct {
	types.ImageCloser
	// contains filtered or unexported fields
}

Image is a Docker-specific implementation of types.ImageCloser with a few extra methods which are specific to Docker.

func (*Image) GetRepositoryTags

func (i *Image) GetRepositoryTags(ctx context.Context) ([]string, error)

GetRepositoryTags list all tags available in the repository. The tag provided inside the ImageReference will be ignored. (This is a backward-compatible shim method which calls the module-level GetRepositoryTags)

func (*Image) SourceRefFullName

func (i *Image) SourceRefFullName() string

SourceRefFullName returns a fully expanded name for the repository this image is in.

type SearchResult

type SearchResult struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	// StarCount states the number of stars the image has
	StarCount int  `json:"star_count"`
	IsTrusted bool `json:"is_trusted"`
	// IsAutomated states whether the image is an automated build
	IsAutomated bool `json:"is_automated"`
	// IsOfficial states whether the image is an official build
	IsOfficial bool `json:"is_official"`
}

SearchResult holds the information of each matching image It matches the output returned by the v1 endpoint

func SearchRegistry

func SearchRegistry(ctx context.Context, sys *types.SystemContext, registry, image string, limit int) ([]SearchResult, error)

SearchRegistry queries a registry for images that contain "image" in their name The limit is the max number of results desired Note: The limit value doesn't work with all registries for example registry.access.redhat.com returns all the results without limiting it to the limit value

type UdistributionTransport added in v0.0.2

type UdistributionTransport struct {
	*client.Client
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(client *client.Client, name string) *UdistributionTransport

Create new transport and register. When you are done with this transport, use Deregister() to unregister it from available transports.

func NewTransportFromNewConfig

func NewTransportFromNewConfig(config string, env []string) (*UdistributionTransport, error)

Create new transport with client params and register. When you are done with this transport, use Deregister() to unregister it from available transports.

func (UdistributionTransport) Deregister added in v0.0.2

func (u UdistributionTransport) Deregister()

func (UdistributionTransport) Name added in v0.0.2

func (t UdistributionTransport) Name() string

func (UdistributionTransport) ParseReference added in v0.0.2

func (t UdistributionTransport) ParseReference(reference string) (types.ImageReference, error)

ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an ImageReference.

func (UdistributionTransport) ValidatePolicyConfigurationScope added in v0.0.2

func (t UdistributionTransport) ValidatePolicyConfigurationScope(scope string) error

ValidatePolicyConfigurationScope checks that scope is a valid name for a signature.PolicyTransportScopes keys (i.e. a valid PolicyConfigurationIdentity() or PolicyConfigurationNamespaces() return value). It is acceptable to allow an invalid value which will never be matched, it can "only" cause user confusion. scope passed to this function will not be "", that value is always allowed.

Directories

Path Synopsis
internal
Package reference provides a general type to represent any way of referencing images within the registry.
Package reference provides a general type to represent any way of referencing images within the registry.
Package tarfile is an internal implementation detail of some transports.
Package tarfile is an internal implementation detail of some transports.

Jump to

Keyboard shortcuts

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