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
- Variables
- func BackoffRoundTripper(r http.RoundTripper, initialBackoff, maxBackoff time.Duration, ...) http.RoundTripper
- func NewMockDockerClient(manifest func(repository, reference string) ([]schema1.History, error), ...) dockerRegistryInterface
- type Cache
- type CachedDockerRegistry
- type Credentials
- type InstrumentedRegistry
- type InstrumentedRemote
- type MemcacheClient
- type MemcacheConfig
- type Registry
- type Remote
- type RemoteClientFactory
- type Repository
Constants ¶
const ( LabelRequestKind = "kind" RequestKindTags = "tags" RequestKindMetadata = "metadata" )
Variables ¶
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
Types ¶
type Cache ¶
type Cache struct { Client MemcacheClient // contains filtered or unexported fields }
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 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 ¶
type RemoteClientFactory ¶
func NewMockRemoteFactory ¶
func NewMockRemoteFactory(r Remote, err error) RemoteClientFactory
func NewRemoteClientFactory ¶
func NewRemoteClientFactory(c Credentials, l log.Logger, mc MemcacheClient, ce time.Duration) 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