testreg

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRegistryBinaryPath = "./tmp/test/bin/registry"

Variables

This section is empty.

Functions

func CreateHtpasswd

func CreateHtpasswd(username, password string) string

CreateHtpasswd creates a htpasswd string for a username and password

func RandString

func RandString(n int) string

RandString creates a random string with n characters.

Types

type Auth

type Auth struct {
	Silly     *SillyAuth     `json:"silly,omitempty"`
	Httpasswd *HttpasswdAuth `json:"htpasswd,omitempty"`
}

Auth describes the authentication mechanism that should be used for the registry. https://github.com/distribution/distribution/blob/main/docs/configuration.md#auth

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth defines auth credentials that consists of a username and a password.

type Certificate

type Certificate struct {
	CA    []byte
	CAKey []byte
	Cert  []byte
	Key   []byte
}

Certificate defines a certificate with a CA. All certs and keys are PEM encoded.

func GenerateCertificates

func GenerateCertificates() (*Certificate, error)

GenerateCertificates generates a new ca and signed cert. Generated cert is only valid for 127.0.0.1. Only use this for testing as insecure keys are used.

type Environment

type Environment struct {
	RegistryBinaryPath    string
	RegistryConfiguration RegistryConfiguration
	ReadinessTimeout      time.Duration
	Stdout                io.Writer
	Stderr                io.Writer

	Certificate *Certificate
	// Contains the host information as soon as the registry is started.
	// The host is of the format "ip:port"
	Addr string
	// Transport to communicate with the registry.
	// Includes the trusted ca.
	Transport *http.Transport
	// BasicAuth defines the basic auth credentials to access the registry.
	BasicAuth *BasicAuth
	// contains filtered or unexported fields
}

func New

func New(opts Options) *Environment

New creates a new test registry environment

func (*Environment) Close

func (e *Environment) Close() error

func (*Environment) GetConfigFileBytes

func (e *Environment) GetConfigFileBytes() ([]byte, error)

GetConfigFileBytes returns the docker configfile containing the registry auth for the registry.

func (*Environment) Start

func (e *Environment) Start(ctx context.Context) error

func (*Environment) WaitForRegistryToBeHealthy

func (e *Environment) WaitForRegistryToBeHealthy() error

type FilesystemStorage

type FilesystemStorage struct {
	RootDirectory string `json:"rootdirectory,omitempty"`
	MaxThreads    int    `json:"maxthreads,omitempty"`
}

type HTTPConfig

type HTTPConfig struct {
	// Defaults to localhost:5000
	Addr   string         `json:"addr,omitempty"`
	Prefix string         `json:"prefix,omitempty"`
	Host   string         `json:"host,omitempty"`
	TLS    *HTTPTLSConfig `json:"tls,omitempty"`
}

type HTTPTLSConfig

type HTTPTLSConfig struct {
	// Cert is the path to the certificate file.
	Cert string `json:"certificate,omitempty"`
	// Key is the path to the key file.
	Key string `json:"key,omitempty"`
	// ClientCas are a list of ca file paths.
	ClientCas []string `json:"clientcas"`
}

type HttpasswdAuth

type HttpasswdAuth struct {
	Realm string `json:"realm"`
	Path  string `json:"path"`
}

HttpasswdAuth allows you to configure basic authentication using an Apache htpasswd file. The only supported password format is bcrypt. Entries with other hash types are ignored. The htpasswd file is loaded once, at startup. If the file is invalid, the registry will display an error and will not start.

type Options

type Options struct {
	RegistryBinaryPath    string
	RegistryConfiguration RegistryConfiguration
	ReadinessTimeout      *time.Duration
	Stdout                io.Writer
	Stderr                io.Writer
}

func (*Options) Default

func (opts *Options) Default()

type RegistryConfiguration

type RegistryConfiguration struct {
	Version    string     `json:"version"`
	Storage    Storage    `json:"storage,omitempty"`
	Auth       Auth       `json:"auth,omitempty"`
	HTTPConfig HTTPConfig `json:"http,omitempty"`
}

RegistryConfiguration contains the docker registry configuration. See https://docs.docker.com/registry/configuration/ for more configuration options

func (*RegistryConfiguration) Default

func (cfg *RegistryConfiguration) Default(tmpDir string) error

Default applies defaults to the registry configuration.

type SillyAuth

type SillyAuth struct {
	Realm string `json:"realm"`
	Path  string `json:"service"`
}

SillyAuth is only appropriate for development. It simply checks for the existence of the Authorization header in the HTTP request. It does not check the header’s value. If the header does not exist, the silly auth responds with a challenge response, echoing back the realm, service, and scope for which access was denied.

type Storage

type Storage struct {
	Filesystem *FilesystemStorage `json:"filesystem,omitempty"`
}

Jump to

Keyboard shortcuts

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