Documentation ¶
Overview ¶
Package registry implements the various functions needed to store and retrieve images from a container registry.
Index ¶
- Constants
- func ExtractImageParts(imageURL string) (string, string, error)
- func Validate(url, namespace, username, password string) error
- type ConnectionDetails
- func (d *ConnectionDetails) DockerConfigJSON() (*DockerConfigJSON, error)
- func (d *ConnectionDetails) PrivateRegistryURL() (string, error)
- func (d *ConnectionDetails) PublicRegistryURL() (string, error)
- func (d *ConnectionDetails) ReplaceWithInternalRegistry(imageURL string) (string, error)
- func (d *ConnectionDetails) Store(ctx context.Context, cluster *kubernetes.Cluster, ...) (*corev1.Secret, error)
- type ContainerRegistryAuth
- type DockerConfigJSON
- type RegistryCredentials
Constants ¶
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 ¶
ExtractImageParts accepts a container image URL and returns the registry and the image parts.
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 DockerConfigJSON ¶
type DockerConfigJSON struct {
Auths map[string]ContainerRegistryAuth `json:"auths"`
}