registry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package registry implements the various functions needed to store and retrieve images from a container registry.

Index

Constants

View Source
const (
	RegistrySecretNamespaceAnnotationKey = "epinio.suse.org/registry-namespace" // nolint:gosec // not credentials
	KubedNamespaceSelector               = "kubed-sync=registry-creds"
	CredentialsSecretName                = "registry-creds"
)

Variables

This section is empty.

Functions

func ExtractImageParts

func ExtractImageParts(imageURL string) (string, string, error)

ExtractImageParts accepts a container image URL and returns the registry and the image parts.

func Validate

func Validate(url, namespace, username, password string) error

Validate makes sure the provided settings are valid The user should provide all the mandatory settings or no settings at all.

Types

type ConnectionDetails

type ConnectionDetails struct {
	RegistryCredentials []RegistryCredentials
	Namespace           string
}

func GetConnectionDetails

func GetConnectionDetails(ctx context.Context, cluster *kubernetes.Cluster, secretNamespace, secretName string) (*ConnectionDetails, error)

GetConnectionDetails retrieves registry connection details from a Kubernetes secret.

func (*ConnectionDetails) DockerConfigJSON added in v0.3.0

func (d *ConnectionDetails) DockerConfigJSON() (*DockerConfigJSON, error)

DockerConfigJSON returns a DockerConfigJSON object from the connection details. This object can be marshaled and stored into a Kubernetes secret.

func (*ConnectionDetails) PrivateRegistryURL

func (d *ConnectionDetails) PrivateRegistryURL() (string, error)

PrivateRegistryURL returns the internal (localhost) registry URL. That url can be used by Kubernetes to pull images only when the internal registry is used and exposed over NodePort. This method will return an empty string if no localhost URL exists in the config.

func (*ConnectionDetails) PublicRegistryURL

func (d *ConnectionDetails) PublicRegistryURL() (string, error)

PublicRegistryURL returns the public registry URL from the connection details object. Assumes to have only one non-local registry in the config. If there are more, it will just return the first one found (no guaranteed order since there should only be one)

func (*ConnectionDetails) ReplaceWithInternalRegistry

func (d *ConnectionDetails) ReplaceWithInternalRegistry(imageURL string) (string, error)

ReplaceWithInternalRegistry replaces the registry part of the given container imageURL with the internal (localhost) URL of the registry when:

  • the imageURL is on the Epinio registry (could be deploying from another registry, with the --container-image-url flag)
  • there is a localhost URL defined on the ConnectionDetails (if we are using an external Epinio registry, there is no need to replace anything and there is no localhost URL defined either).

func (*ConnectionDetails) Store

func (d *ConnectionDetails) Store(ctx context.Context, cluster *kubernetes.Cluster, secretNamespace, secretName string) (*corev1.Secret, error)

Store stores the connection details in a secret. The registry namespace (or org) is stored in an annotation (because Kubernetes expects the secret in a specific format). It is used to construct the full url to an application image in the form: registryURL/registryNamespace/appImage

type ContainerRegistryAuth

type ContainerRegistryAuth struct {
	Auth     string `json:"auth"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths map[string]ContainerRegistryAuth `json:"auths"`
}

type RegistryCredentials

type RegistryCredentials struct {
	URL      string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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