imagetranslation

package
v0.9.4-test3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 25 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCRDRestClient

func GetCRDRestClient(cfg *rest.Config) (*rest.RESTClient, error)

GetCRDRestClient returns ReST client that can be used to work with virtlet CRDs

func RegisterCustomResourceType

func RegisterCustomResourceType() error

RegisterCustomResourceType registers custom resource definition for VirtletImageMapping kind in k8s

Types

type ConfigSource

type ConfigSource interface {
	// Configs returns list of configs that are available in this data source
	Configs(ctx context.Context) ([]TranslationConfig, error)

	// Description returns the data-source description to be used in the logs
	Description() string
}

ConfigSource is the data-source for translation configs

func NewCRDSource

func NewCRDSource(namespace string) ConfigSource

NewCRDSource is a factory for CRD-based config source

func NewFakeConfigSource

func NewFakeConfigSource(configs map[string]ImageTranslation) ConfigSource

NewFakeConfigSource is a factory for a fake config source

func NewFileConfigSource

func NewFileConfigSource(configsDirectory string) ConfigSource

NewFileConfigSource is a factory for a directory-based config source

type ImageNameTranslator

type ImageNameTranslator interface {
	// LoadConfigs initializes translator with configs from supplied data sources. All previous mappings are discarded.
	LoadConfigs(ctx context.Context, sources ...ConfigSource)

	// Translate translates image name to ins Endpoint. If no suitable mapping was found, the default Endpoint is returned
	Translate(name string) image.Endpoint
}

ImageNameTranslator is the main translator interface

func NewImageNameTranslator

func NewImageNameTranslator() ImageNameTranslator

NewImageNameTranslator creates an instance of ImageNameTranslator

type ImageTranslation

type ImageTranslation struct {
	// Prefix allows to have several config-sets and distinguish them by using `prefix/imageName` notation. Optional.
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// Rules is a list of translations
	Rules []TranslationRule `yaml:"translations" json:"translations"`

	// Transports is a map of available transport profiles available for endpoints
	Transports map[string]TransportProfile `yaml:"transports" json:"transports"`
}

ImageTranslation is a single translation config with optional prefix name

type TLSCertificate

type TLSCertificate struct {
	// Cert certificate (PEM) block
	Cert string `yaml:"cert,omitempty" json:"cert,omitempty"`

	// Key - keypair (PEM) block
	Key string `yaml:"key,omitempty" json:"key,omitempty"`
}

TLSCertificate has the x509 certificate PEM data with optional PEM private key

type TLSConfig

type TLSConfig struct {
	// Certificates - TLS certificates to use for connection
	Certificates []TLSCertificate `yaml:"certificates,omitempty" json:"certificates,omitempty"`

	// ServerName is used to verify the hostname on the returned certificates. Needed when url points to domain that
	// differs from CN of certificate
	ServerName string `yaml:"serverName,omitempty" json:"serverName,omitempty"`

	// Insecure is a flag to bypass server certificate validation
	Insecure bool `yaml:"insecure,omitempty" json:"insecure,omitempty"`
}

TLSConfig has the TLS transport parameters

type TranslationConfig

type TranslationConfig interface {
	// Name returns the config name (any string identifier)
	Name() string

	// Payload returns ImageTranslation object associated with the config
	Payload() (ImageTranslation, error)
}

TranslationConfig represents a single config (prefix + rule list) in a config-set

type TranslationRule

type TranslationRule struct {
	// Name defines a mapping from a fixed name
	Name string `yaml:"name,omitempty" json:"name,omitempty"`

	// Regex defines a mapping from all names that match this regexp. In this case replacements can be used for Endpoint.Url
	Regex string `yaml:"regexp,omitempty" json:"regexp,omitempty"`

	// Url is the image URL
	Url string `yaml:"url,omitempty" json:"url,omitempty"`

	// Transport is the optional transport profile name to be used for the downloading
	Transport string `yaml:"transport,omitempty" json:"transport,omitempty"`
}

TranslationRule represents a single translation rule from either name or regexp to Endpoint

type TransportProfile

type TransportProfile struct {
	// MaxRedirects is the maximum number of redirects that downloader is allowed to follow. Default is 9 (download fails on request #10)
	MaxRedirects *int `yaml:"maxRedirects,omitempty" json:"maxRedirects,omitempty"`

	// TLS config
	TLS *TLSConfig `yaml:"tls,omitempty" json:"tls,omitempty"`

	// TimeoutMilliseconds specifies a time limit in milliseconds for http(s) download request. <= 0 is no timeout (default)
	TimeoutMilliseconds int `yaml:"timeout,omitempty" json:"timeout,omitempty"`

	// Proxy server to use for downloading
	Proxy string `yaml:"proxy,omitempty" json:"proxy,omitempty"`
}

TransportProfile contains all the http transport settings

type VirtletImageMapping

type VirtletImageMapping struct {
	meta_v1.TypeMeta   `json:",inline"`
	meta_v1.ObjectMeta `json:"metadata"`
	Spec               ImageTranslation `json:"spec"`
}

VirtletImageMapping represents an ImageTranslation wrapped in k8s object

func (VirtletImageMapping) Name

func (vim VirtletImageMapping) Name() string

Name implements TranslationConfig Name

func (VirtletImageMapping) Payload

func (vim VirtletImageMapping) Payload() (ImageTranslation, error)

Payload implements TranslationConfig Payload

type VirtletImageMappingList

type VirtletImageMappingList struct {
	meta_v1.TypeMeta `json:",inline"`
	meta_v1.ListMeta `json:"metadata"`
	Items            []VirtletImageMapping `json:"items"`
}

VirtletImageMappingList is a k8s representation of list of translation configs

Jump to

Keyboard shortcuts

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