registries

package
v0.0.0-...-e779149 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusFailed  = "failed"
	StatusSuccess = "succeeded"
)
View Source
const (
	// DefaultDockerRegistry is the default docker registry address.
	DefaultDockerRegistry = "https://registry-1.docker.io"

	DefaultDockerHub = "docker.io"

	DefaultTimeout = 30 * time.Second
)

Variables

View Source
var (

	// ErrBasicAuth indicates that the repository requires basic rather than token authentication.
	ErrBasicAuth = errors.New("basic auth required")
)

Functions

func GetAuthConfig

func GetAuthConfig(username, password, registry string) (types.AuthConfig, error)

GetAuthConfig returns the docker registry AuthConfig.

func GetRespBody

func GetRespBody(resp *http.Response) ([]byte, error)

Decompress response.body.

Types

type Config

type Config struct {
	HostName     string                 `json:"Hostname,omitempty" description:"A string value containing the hostname to use for the container."`
	DomainName   string                 `json:"Domainname,omitempty" description:"A string value containing the domain name to use for the container."`
	User         string                 `json:"User,omitempty" description:"A string value specifying the user inside the container."`
	AttachStdin  bool                   `json:"AttachStdin,omitempty" description:"Boolean value, attaches to stdin."`
	AttachStdout bool                   `json:"AttachStdout,omitempty" description:"Boolean value, attaches to stdout."`
	AttachStderr bool                   `json:"AttachStderr,omitempty" description:"Boolean value, attaches to stderr."`
	ExposedPorts map[string]interface{} `` /* 149-byte string literal not displayed */
	Tty          bool                   `json:"Tty,omitempty" description:"Boolean value, Attach standard streams to a tty, including stdin if it is not closed."`
	OpenStdin    bool                   `json:"OpenStdin,omitempty" description:"Boolean value, opens stdin"`
	StdinOnce    bool                   `json:"StdinOnce,omitempty" description:"Boolean value, close stdin after the 1 attached client disconnects."`
	Env          []string               `json:"Env,omitempty" description:"A list of environment variables in the form of [\"VAR=value\", ...]"`
	Cmd          []string               `json:"Cmd,omitempty" description:"Command to run specified as a string or an array of strings."`
	ArgsEscaped  bool                   `json:"ArgsEscaped,omitempty" description:"Command is already escaped (Windows only)"`
	Image        string                 `json:"Image,omitempty" description:"A string specifying the image name to use for the container."`
	Volumes      interface{}            `json:"Volumes,omitempty" description:"An object mapping mount point paths (strings) inside the container to empty objects."`
	WorkingDir   string                 `json:"WorkingDir,omitempty" description:"A string specifying the working directory for commands to run in."`
	Entrypoint   interface{}            `json:"Entrypoint,omitempty" description:"The entry point set for the container as a string or an array of strings."`
	OnBuild      interface{}            `json:"OnBuild,omitempty" description:"ONBUILD metadata that were defined in the image's Dockerfile."`
	Labels       Labels                 `json:"Labels,omitempty" description:"The map of labels to a container."`
	StopSignal   string                 `json:"StopSignal,omitempty" description:"Signal to stop a container as a string or unsigned integer."`
}

type ContainerConfig

type ContainerConfig struct {
	HostName     string                 `json:"Hostname,omitempty" description:"A string value containing the hostname to use for the container."`
	DomainName   string                 `json:"Domainname,omitempty" description:"A string value containing the domain name to use for the container."`
	User         string                 `json:"User,omitempty" description:"A string value specifying the user inside the container."`
	AttachStdin  bool                   `json:"AttachStdin,omitempty" description:"Boolean value, attaches to stdin."`
	AttachStdout bool                   `json:"AttachStdout,omitempty" description:"Boolean value, attaches to stdout."`
	AttachStderr bool                   `json:"AttachStderr,omitempty" description:"Boolean value, attaches to stderr."`
	ExposedPorts map[string]interface{} `` /* 149-byte string literal not displayed */
	Tty          bool                   `json:"Tty,omitempty" description:"Boolean value, Attach standard streams to a tty, including stdin if it is not closed."`
	OpenStdin    bool                   `json:"OpenStdin,omitempty" description:"Boolean value, opens stdin"`
	StdinOnce    bool                   `json:"StdinOnce,omitempty" description:"Boolean value, close stdin after the 1 attached client disconnects."`
	Env          []string               `json:"Env,omitempty" description:"A list of environment variables in the form of [\"VAR=value\", ...]"`
	Cmd          []string               `json:"Cmd,omitempty" description:"Command to run specified as a string or an array of strings."`
	ArgsEscaped  bool                   `json:"ArgsEscaped,omitempty" description:"Command is already escaped (Windows only)"`
	Image        string                 `json:"Image,omitempty" description:"A string specifying the image name to use for the container."`
	Volumes      interface{}            `json:"Volumes,omitempty" description:"An object mapping mount point paths (strings) inside the container to empty objects."`
	WorkingDir   string                 `json:"WorkingDir,omitempty" description:"A string specifying the working directory for commands to run in."`
	EntryPoint   interface{}            `json:"Entrypoint,omitempty" description:"The entry point set for the container as a string or an array of strings."`
	OnBuild      interface{}            `json:"OnBuild,omitempty" description:"ONBUILD metadata that were defined in the image's Dockerfile."`
	Labels       Labels                 `json:"Labels,omitempty" description:"The map of labels to a container."`
	StopSignal   string                 `json:"StopSignal,omitempty" description:"Signal to stop a container as a string or unsigned integer."`
}

type DockerConfigEntry

type DockerConfigEntry struct {
	Username      string `json:"username"`
	Password      string `json:"password"`
	Email         string `json:"email"`
	ServerAddress string `json:"serverAddress,omitempty"`
}

type DockerConfigJson

type DockerConfigJson struct {
	Auths DockerConfigMap `json:"auths"`
}

type DockerConfigMap

type DockerConfigMap map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI. This config that represents the credentials that should be used when pulling images from specific image repositories.

type DockerURL

type DockerURL struct {
	*url.URL
}

func ParseDockerURL

func ParseDockerURL(rawurl string) (*DockerURL, error)

func (*DockerURL) StringWithoutScheme

func (u *DockerURL) StringWithoutScheme() string

type History

type History struct {
	Created    time.Time `json:"created,omitempty" description:"Created time."`
	CreatedBy  string    `json:"created_by,omitempty" description:"Created command."`
	EmptyLayer bool      `json:"empty_layer,omitempty" description:"Layer empty or not."`
}

type Image

type Image struct {
	Domain string
	Path   string
	Tag    string
	Digest digest.Digest
	// contains filtered or unexported fields
}

Image holds information about an image.

func ParseImage

func ParseImage(image string) (i Image, err error)

ParseImage returns an Image struct with all the values filled in for a given image. example : localhost:5000/nginx:latest, nginx:perl etc.

func (*Image) Reference

func (i *Image) Reference() string

Reference returns either the digest if it is non-empty or the tag for the image.

func (*Image) String

func (i *Image) String() string

String returns the string representation of an image.

type ImageBlob

type ImageBlob struct {
	Architecture    string          `` /* 128-byte string literal not displayed */
	Config          Config          `json:"config,omitempty" description:"The config field references a configuration object for a container."`
	Container       string          `json:"container,omitempty" description:"Container id."`
	ContainerConfig ContainerConfig `json:"container_config,omitempty" description:"The config data of container."`
	Created         time.Time       `json:"created,omitempty" description:"Create time."`
	DockerVersion   string          `json:"docker_version,omitempty" description:"docker version."`
	History         []History       `json:"history,omitempty" description:"The data of history update."`
	Os              string          `json:"os,omitempty" description:"Operating system."`
	Rootfs          Rootfs          `json:"rootfs omitempty" description:"Root filesystem."`
}

type ImageDetails

type ImageDetails struct {
	// Status is the status of the image search, such as "failed","succeeded".
	Status        string         `json:"status,omitempty" description:"Status is the status of the image search, such as \"succeeded\"."`
	Message       string         `json:"message,omitempty" description:"Status message."`
	ImageManifest *ImageManifest `` /* 159-byte string literal not displayed */
	ImageBlob     *ImageBlob     `` /* 147-byte string literal not displayed */
	ImageTag      string         `json:"imageTag,omitempty" description:"image tag."`
	Registry      string         `json:"registry,omitempty" description:"registry domain."`
}

ImageBlobInfo describes the info of an image.

type ImageManifest

type ImageManifest struct {
	SchemaVersion  int            `json:"schemaVersion,omitempty" description:"This field specifies the image manifest schema version as an integer."`
	MediaType      string         `json:"mediaType,omitempty" description:"The MIME type of the manifest."`
	ManifestConfig ManifestConfig `json:"config,omitempty" description:"The config field references a configuration object for a container."`
	Layers         []Layers       `json:"layers,omitempty" description:"Fields of an item in the layers list."`
}

type Labels

type Labels struct {
	Maintainer string `json:"maintainer" description:""`
}

type Layers

type Layers struct {
	MediaType string `json:"mediaType,omitempty" description:"The MIME type of the layer."`
	Size      int    `json:"size,omitempty" description:"The size in bytes of the layer."`
	Digest    string `` /* 189-byte string literal not displayed */
}

type ManifestConfig

type ManifestConfig struct {
	MediaType string        `json:"mediaType,omitempty" description:"The MIME type of the image."`
	Size      int           `json:"size,omitempty" description:"The size in bytes of the image."`
	Digest    digest.Digest `` /* 189-byte string literal not displayed */
}

type Registry

type Registry struct {
	URL      string
	Domain   string
	Username string
	Password string
	Client   *http.Client
	Opt      RegistryOpt
}

Registry defines the client for retrieving information from the registry API.

func CreateRegistryClient

func CreateRegistryClient(username, password, domain string, useSSL bool, insecure bool) (*Registry, error)

func New

func New(auth types.AuthConfig, opt RegistryOpt) (*Registry, error)

New creates a new Registry struct with the given URL and credentials.

func (*Registry) GetBlobUrl

func (r *Registry) GetBlobUrl(image Image) string

func (*Registry) GetDigestUrl

func (r *Registry) GetDigestUrl(image Image) string

func (*Registry) ImageBlob

func (r *Registry) ImageBlob(image Image, token string) (*ImageBlob, error)

Digest returns the digest for an image.

func (*Registry) ImageManifest

func (r *Registry) ImageManifest(image Image, token string) (*ImageManifest, error)

Digest returns the digest for an image.

func (*Registry) Token

func (r *Registry) Token(url string) (str string, err error)

Token returns the required token for the specific resource url. If the registry requires basic authentication, this function returns ErrBasicAuth.

type RegistryGetter

type RegistryGetter interface {
	VerifyRegistryCredential(credential api.RegistryCredential) error
	GetEntry(namespace, secretName, imageName string, insecure bool) (ImageDetails, error)
}

func NewRegistryGetter

func NewRegistryGetter(informers informers.SharedInformerFactory) RegistryGetter

type RegistryOpt

type RegistryOpt struct {
	Domain   string
	Timeout  time.Duration
	Headers  map[string]string
	UseSSL   bool
	Insecure bool
}

Opt holds the options for a new registry.

type Rootfs

type Rootfs struct {
	Type    string   `json:"type,omitempty" description:"Root filesystem type, always \"layers\" "`
	DiffIds []string `json:"diff_ids,omitempty" description:"Contain ids of layer list"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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