registry

package
v0.3.0-prep Latest Latest
Warning

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

Go to latest
Published: May 4, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Monitoring middlewares for registry interfaces

Package registry provides domain abstractions over container registries.

We can't inject a remote client directly because each repository request might be to a different registry provider. E.g. both docker hub and quay containers. So a new remote client must be created for each new Image. This factory provides that and can be mocked out.

Index

Constants

View Source
const (
	LabelRequestKind = "kind"

	RequestKindTags     = "tags"
	RequestKindMetadata = "metadata"
)

Variables

View Source
var (
	ErrTimeout = errors.New("http request timeout")
)

Functions

func BackoffRoundTripper

func BackoffRoundTripper(r http.RoundTripper, initialBackoff, maxBackoff time.Duration, clock clockwork.Clock) http.RoundTripper

BackoffRoundTripper is a http.RoundTripper which adds a backoff for throttling to requests. To add a total request timeout, use Request.WithContext.

r -- upstream roundtripper initialBackoff -- initial length to backoff to when request request fails maxBackoff -- maximum length to backoff to between request attempts

func NewMockDockerClient

func NewMockDockerClient(manifest func(repository, reference string) ([]schema1.History, error), tags func(repository string) ([]string, error)) dockerRegistryInterface

Types

type Cache

type Cache struct {
	Client MemcacheClient
	// contains filtered or unexported fields
}

func (*Cache) Manifest

func (c *Cache) Manifest(repository, reference string) ([]schema1.History, error)

func (*Cache) Tags

func (c *Cache) Tags(repository string) ([]string, error)

Pass through. Not caching tags.

type CachedDockerRegistry

type CachedDockerRegistry func(dockerRegistryInterface) dockerRegistryInterface

func NewCache

func NewCache(creds Credentials, cache MemcacheClient, expiry time.Duration, logger log.Logger) CachedDockerRegistry

type Credentials

type Credentials struct {
	// contains filtered or unexported fields
}

Credentials to a (Docker) registry.

func CredentialsFromConfig

func CredentialsFromConfig(config flux.UnsafeInstanceConfig) (Credentials, error)

func NoCredentials

func NoCredentials() Credentials

NoCredentials returns a usable but empty credentials object.

func (Credentials) Hosts

func (cs Credentials) Hosts() []string

Hosts returns all of the hosts available in these credentials.

type InstrumentedRegistry

type InstrumentedRegistry Registry

func NewInstrumentedRegistry

func NewInstrumentedRegistry(next Registry) InstrumentedRegistry

type InstrumentedRemote

type InstrumentedRemote Remote

type MemcacheClient

type MemcacheClient interface {
	Add(item *memcache.Item) error
	CompareAndSwap(item *memcache.Item) error
	Decrement(key string, delta uint64) (newValue uint64, err error)
	Delete(key string) error
	DeleteAll() error
	FlushAll() error
	Get(key string) (item *memcache.Item, err error)
	GetMulti(keys []string) (map[string]*memcache.Item, error)
	Increment(key string, delta uint64) (newValue uint64, err error)
	Replace(item *memcache.Item) error
	Set(item *memcache.Item) error
	Touch(key string, seconds int32) (err error)

	Stop()
}

func InstrumentMemcacheClient

func InstrumentMemcacheClient(c MemcacheClient) MemcacheClient

func NewMemcacheClient

func NewMemcacheClient(config MemcacheConfig) MemcacheClient

type MemcacheConfig

type MemcacheConfig struct {
	Host           string
	Service        string
	Timeout        time.Duration
	UpdateInterval time.Duration
	Logger         log.Logger
}

MemcacheConfig defines how a MemcacheClient should be constructed.

type Registry

type Registry interface {
	GetRepository(repository Repository) ([]flux.Image, error)
	GetImage(repository Repository, tag string) (flux.Image, error)
}

The Registry interface is a domain specific API to access container registries.

func NewMockRegistry

func NewMockRegistry(images []flux.Image, err error) Registry

func NewRegistry

func NewRegistry(c RemoteClientFactory, l log.Logger) Registry

NewClient creates a new registry registry, to use when fetching repositories.

type Remote

type Remote interface {
	Tags(repository Repository) ([]string, error)
	Manifest(repository Repository, tag string) (flux.Image, error)
	Cancel()
}

func NewInstrumentedRemote

func NewInstrumentedRemote(next Remote) Remote

func NewMockRemote

func NewMockRemote(img flux.Image, tags []string, err error) Remote

type RemoteClientFactory

type RemoteClientFactory interface {
	CreateFor(host string) (Remote, error)
}

func NewMockRemoteFactory

func NewMockRemoteFactory(r Remote, err error) RemoteClientFactory

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func ParseRepository

func ParseRepository(imgStr string) (Repository, error)

func RepositoryFromImage

func RepositoryFromImage(img flux.Image) Repository

func (Repository) Host

func (r Repository) Host() string

func (Repository) NamespaceImage

func (r Repository) NamespaceImage() string

func (Repository) String

func (r Repository) String() string

func (Repository) ToImage

func (r Repository) ToImage(tag string) flux.Image

Jump to

Keyboard shortcuts

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