registry

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChartFormatMatcher = regexp.MustCompile("(.*)-(.*).tgz")

ChartFormatMatcher matches the chart name format

View Source
var GCSRegistryMatcher = regexp.MustCompile("gs://(.*)/(.*)")

RE for GCS storage

View Source
var PackageRegistryMatcher = regexp.MustCompile("github.com/(.*)/(.*)/(.*)")

RE for a registry type that does not support versions and does not have collections.

View Source
var TemplateRegistryMatcher = regexp.MustCompile("github.com/(.*)/(.*)/(.*)/(.*):(.*)")

RE for a registry type that does support versions and has collections.

View Source
var URLFormatMatcher = regexp.MustCompile("gs://(.*)")

URLFormatMatcher matches the GCS URL format (gs:).

Functions

func IsGCSShortType

func IsGCSShortType(t string) bool

IsGCSShortType returns whether a given type is a type description in a short format to GCS

func IsGithubShortPackageType

func IsGithubShortPackageType(t string) bool

IsGithubShortPackageType returns whether a given type is a type description in a short format to a github package repository type. For now, this means using github types: github.com/owner/repo/type for example: github.com/helm/charts/cassandra

func IsGithubShortType

func IsGithubShortType(t string) bool

IsGithubShortType returns whether a given type is a type description in a short format to a github repository type. For now, this means using github types: github.com/owner/repo/qualifier/type:version for example: github.com/kubernetes/application-dm-templates/storage/redis:v1

func NewFilebasedCredentialProvider

func NewFilebasedCredentialProvider(filename string) (common.CredentialProvider, error)

NewFilebasedCredentialProvider creates a file based credential provider.

func NewInmemCredentialProvider

func NewInmemCredentialProvider() common.CredentialProvider

NewInmemCredentialProvider creates a new memory based credential provider.

func NewInmemRegistryService

func NewInmemRegistryService() common.RegistryService

NewInmemRegistryService returns a new memory based registry service.

func NewSecretsCredentialProvider

func NewSecretsCredentialProvider() common.CredentialProvider

NewSecretsCredentialProvider creates a new secrets credential provider.

func ParseRegistryFormat

func ParseRegistryFormat(rf common.RegistryFormat) map[common.RegistryFormat]bool

ParseRegistryFormat creates a map from a registry format string.

Types

type DownloadResponse

type DownloadResponse struct {
	Err  error
	Code int
	Body string
}

DownloadResponse holds a mock http response for testing.

type FilebasedCredentialProvider

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

FilebasedCredentialProvider provides credentials for registries.

func (*FilebasedCredentialProvider) GetCredential

func (fcp *FilebasedCredentialProvider) GetCredential(name string) (*common.RegistryCredential, error)

GetCredential returns a credential by name.

func (*FilebasedCredentialProvider) SetCredential

func (fcp *FilebasedCredentialProvider) SetCredential(name string, credential *common.RegistryCredential) error

SetCredential sets a credential by name.

type GCSRegistry

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

GCSRegistry implements the ObbectStorageRegistry interface and implements a Deployment Manager templates registry.

A registry root must be a directory that contains all the available charts, one or two files per template. name-version.tgz name-version.prov

func NewGCSRegistry

func NewGCSRegistry(name, shortURL string, httpClient *http.Client, gcsService *storage.Service) (*GCSRegistry, error)

NewGCSRegistry creates a GCS registry.

func (GCSRegistry) Do

func (g GCSRegistry) Do(req *http.Request) (resp *http.Response, err error)

Do performs an HTTP operation on the receiver's httpClient.

func (GCSRegistry) GetBucket

func (g GCSRegistry) GetBucket() string

GetBucket returns the registry bucket.

func (GCSRegistry) GetDownloadURLs

func (g GCSRegistry) GetDownloadURLs(t Type) ([]*url.URL, error)

GetDownloadURLs fetches the download URLs for a given Chart

func (GCSRegistry) GetRegistryFormat

func (g GCSRegistry) GetRegistryFormat() common.RegistryFormat

GetRegistryFormat returns the registry format.

func (GCSRegistry) GetRegistryName

func (g GCSRegistry) GetRegistryName() string

GetRegistryName returns the name of the registry.

func (GCSRegistry) GetRegistryShortURL

func (g GCSRegistry) GetRegistryShortURL() string

GetRegistryShortURL returns the short URL for the registry.

func (GCSRegistry) GetRegistryType

func (g GCSRegistry) GetRegistryType() common.RegistryType

GetRegistryType returns the registry type.

func (GCSRegistry) ListTypes

func (g GCSRegistry) ListTypes(regex *regexp.Regexp) ([]Type, error)

ListTypes lists types in this registry whose string values conform to the supplied regular expression, or all types, if the regular expression is nil.

type GCSRegistryProvider

type GCSRegistryProvider interface {
	GetGCSRegistry(cr common.Registry) (ObjectStorageRegistry, error)
}

GCSRegistryProvider is a factory for GCS Registry instances.

func NewGCSRegistryProvider

func NewGCSRegistryProvider(cp common.CredentialProvider) GCSRegistryProvider

NewGCSRegistryProvider creates a GCSRegistryProvider.

func NewTestGCSRegistryProvider

func NewTestGCSRegistryProvider(shortURL string, responses map[Type]TestURLAndError) GCSRegistryProvider

NewTestGCSRegistryProvider creates a test GCS registry provider.

type GithubPackageRegistry

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

GithubPackageRegistry implements the Registry interface that talks to github and expects packages in helm format without versioning and no collection in the path. Format of the directory for a type is like so: package/

Chart.yaml
manifests/
  foo.yaml
  bar.yaml
  ...

func NewGithubPackageRegistry

func NewGithubPackageRegistry(name, shortURL string, service GithubRepositoryService, httpClient *http.Client, client *github.Client) (*GithubPackageRegistry, error)

NewGithubPackageRegistry creates a GithubPackageRegistry.

func (GithubPackageRegistry) Do

func (g GithubPackageRegistry) Do(req *http.Request) (resp *http.Response, err error)

Do performs an HTTP operation on the receiver's httpClient.

func (GithubPackageRegistry) GetDownloadURLs

func (g GithubPackageRegistry) GetDownloadURLs(t Type) ([]*url.URL, error)

GetDownloadURLs fetches the download URLs for a given Type.

func (GithubPackageRegistry) GetRegistryFormat

func (g GithubPackageRegistry) GetRegistryFormat() common.RegistryFormat

GetRegistryFormat returns the format of this registry.

func (GithubPackageRegistry) GetRegistryName

func (g GithubPackageRegistry) GetRegistryName() string

GetRegistryName returns the name of this registry

func (GithubPackageRegistry) GetRegistryOwner

func (g GithubPackageRegistry) GetRegistryOwner() string

GetRegistryOwner returns the owner name for this registry

func (GithubPackageRegistry) GetRegistryPath

func (g GithubPackageRegistry) GetRegistryPath() string

GetRegistryName returns the name of this registry

func (GithubPackageRegistry) GetRegistryRepository

func (g GithubPackageRegistry) GetRegistryRepository() string

GetRegistryRepository returns the repository name for this registry.

func (GithubPackageRegistry) GetRegistryShortURL

func (g GithubPackageRegistry) GetRegistryShortURL() string

GetRegistryShortURL returns the short URL for this registry.

func (GithubPackageRegistry) GetRegistryType

func (g GithubPackageRegistry) GetRegistryType() common.RegistryType

GetRegistryType returns the type of this registry.

func (GithubPackageRegistry) ListTypes

func (g GithubPackageRegistry) ListTypes(regex *regexp.Regexp) ([]Type, error)

ListTypes lists types in this registry whose string values conform to the supplied regular expression, or all types, if the regular expression is nil.

func (GithubPackageRegistry) MakeRepositoryPath

func (g GithubPackageRegistry) MakeRepositoryPath(t Type) (string, error)

MakeRepositoryPath constructs a github path to a given type based on a repository, and type name. The returned repository path will be of the form: Type.Name/manifests

type GithubRegistry

type GithubRegistry interface {
	Registry // A GithubRegistry is a Registry.
	// GetRegistryOwner returns the owner name for this registry
	GetRegistryOwner() string
	// GetRegistryRepository returns the repository name for this registry.
	GetRegistryRepository() string
	// GetRegistryPath returns the path to the registry in the repository.
	GetRegistryPath() string
}

GithubRegistry abstracts a registry that resides in a Github repository.

type GithubRegistryProvider

type GithubRegistryProvider interface {
	GetGithubRegistry(cr common.Registry) (GithubRegistry, error)
}

GithubRegistryProvider is a factory for GithubRegistry instances.

func NewGithubRegistryProvider

func NewGithubRegistryProvider(cp common.CredentialProvider) GithubRegistryProvider

NewGithubRegistryProvider creates a GithubRegistryProvider.

func NewTestGithubRegistryProvider

func NewTestGithubRegistryProvider(shortURL string, responses map[Type]TestURLAndError) GithubRegistryProvider

NewTestGithubRegistryProvider creates a test github registry provider.

func NewTestGithubRegistryProviderWithDownloads

func NewTestGithubRegistryProviderWithDownloads(shortURL string, responses map[Type]TestURLAndError, downloadResponses map[string]DownloadResponse) GithubRegistryProvider

NewTestGithubRegistryProviderWithDownloads creates a test github registry provider with download responses.

type GithubRepositoryService

type GithubRepositoryService interface {
	GetContents(
		owner, repo, path string,
		opt *github.RepositoryContentGetOptions,
	) (
		fileContent *github.RepositoryContent,
		directoryContent []*github.RepositoryContent,
		resp *github.Response,
		err error,
	)
}

GithubRepositoryService defines the interface that's defined in github.com/go-github/repos_contents.go GetContents method.

type GithubTemplateRegistry

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

GithubTemplateRegistry implements the Registry interface and implements a Deployment Manager templates registry. A registry root must be a directory that contains all the available templates, one directory per template. Each template directory then contains version directories, each of which in turn contains all the files necessary for that version of the template.

For example, a template registry containing two versions of redis (implemented in jinja), and one version of replicatedservice (implemented in python) would have a directory structure that looks something like this: qualifier [optional] prefix to a virtual root within the repository. /redis

/v1
  redis.jinja
  redis.jinja.schema
/v2
  redis.jinja
  redis.jinja.schema

/replicatedservice

/v1
  replicatedservice.python
  replicatedservice.python.schema

func NewGithubTemplateRegistry

func NewGithubTemplateRegistry(name, shortURL string, service GithubRepositoryService, httpClient *http.Client, client *github.Client) (*GithubTemplateRegistry, error)

NewGithubTemplateRegistry creates a GithubTemplateRegistry.

func (GithubTemplateRegistry) Do

func (g GithubTemplateRegistry) Do(req *http.Request) (resp *http.Response, err error)

Do performs an HTTP operation on the receiver's httpClient.

func (GithubTemplateRegistry) GetDownloadURLs

func (g GithubTemplateRegistry) GetDownloadURLs(t Type) ([]*url.URL, error)

GetDownloadURLs fetches the download URLs for a given Type and checks for existence of a schema file.

func (GithubTemplateRegistry) GetRegistryFormat

func (g GithubTemplateRegistry) GetRegistryFormat() common.RegistryFormat

GetRegistryFormat returns the format of this registry.

func (GithubTemplateRegistry) GetRegistryName

func (g GithubTemplateRegistry) GetRegistryName() string

GetRegistryName returns the name of this registry

func (GithubTemplateRegistry) GetRegistryOwner

func (g GithubTemplateRegistry) GetRegistryOwner() string

GetRegistryOwner returns the owner name for this registry

func (GithubTemplateRegistry) GetRegistryPath

func (g GithubTemplateRegistry) GetRegistryPath() string

GetRegistryName returns the name of this registry

func (GithubTemplateRegistry) GetRegistryRepository

func (g GithubTemplateRegistry) GetRegistryRepository() string

GetRegistryRepository returns the repository name for this registry.

func (GithubTemplateRegistry) GetRegistryShortURL

func (g GithubTemplateRegistry) GetRegistryShortURL() string

GetRegistryShortURL returns the short URL for this registry.

func (GithubTemplateRegistry) GetRegistryType

func (g GithubTemplateRegistry) GetRegistryType() common.RegistryType

GetRegistryType returns the type of this registry.

func (GithubTemplateRegistry) ListTypes

func (g GithubTemplateRegistry) ListTypes(regex *regexp.Regexp) ([]Type, error)

ListTypes lists types in this registry whose string values conform to the supplied regular expression, or all types, if the regular expression is nil.

func (GithubTemplateRegistry) MakeRepositoryPath

func (g GithubTemplateRegistry) MakeRepositoryPath(t Type) (string, error)

MakeRepositoryPath constructs a github path to a given type based on a repository, and type name and version. The returned repository path will be of the form: [GithubTemplateRegistry.path/][Type.Collection]/Type.Name/Type.Version Type.Collection will be mapped using mapCollection in the future, for now it's a straight 1:1 mapping (if given)

type InmemCredentialProvider

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

InmemCredentialProvider is a memory based credential provider.

func (*InmemCredentialProvider) GetCredential

func (fcp *InmemCredentialProvider) GetCredential(name string) (*common.RegistryCredential, error)

GetCredential returns a credential by name.

func (*InmemCredentialProvider) SetCredential

func (fcp *InmemCredentialProvider) SetCredential(name string, credential *common.RegistryCredential) error

SetCredential sets a credential by name.

type NamedRegistryCredential

type NamedRegistryCredential struct {
	Name string `json:"name,omitempty"`
	common.RegistryCredential
}

NamedRegistryCredential associates a name with a RegistryCredential.

type ObjectStorageRegistry

type ObjectStorageRegistry interface {
	Registry // An ObjectStorageRegistry is a Registry.
	GetBucket() string
}

ObjectStorageRegistry abstracts a registry that resides in an Object Storage, for example Google Cloud Storage or AWS S3, etc.

type Registry

type Registry interface {
	// Also handles http.Client.Do method for authenticated File accesses
	util.HTTPDoer

	// GetRegistryName returns the name of this registry
	GetRegistryName() string
	// GetRegistryType returns the type of this registry.
	GetRegistryType() common.RegistryType
	// GetRegistryShortURL returns the short URL for this registry.
	GetRegistryShortURL() string
	// GetRegistryFormat returns the format of this registry.
	GetRegistryFormat() common.RegistryFormat

	// ListTypes lists types in this registry whose string values conform to the
	// supplied regular expression, or all types, if the regular expression is nil.
	ListTypes(regex *regexp.Regexp) ([]Type, error)
	// GetDownloadURLs returns the URLs required to download the type contents.
	GetDownloadURLs(t Type) ([]*url.URL, error)
}

Registry abstracts a registry that holds charts, which can be used in a Deployment Manager configuration. There can be multiple registry implementations.

func GetDownloadURLs

func GetDownloadURLs(rp RegistryProvider, t string) ([]string, Registry, error)

GetDownloadURLs checks a type to see if it is either a short git hub url or a fully specified URL and returns the URLs that should be used to fetch it. If the url is not fetchable (primitive type for example), it returns an empty slice.

func ShortTypeToDownloadURLs

func ShortTypeToDownloadURLs(rp RegistryProvider, t string) ([]string, Registry, error)

ShortTypeToDownloadURLs converts a github URL into downloadable URL from github. Input must be of the type and is assumed to have been validated before this call: github.com/owner/repo/qualifier/type:version for example: github.com/kubernetes/application-dm-templates/storage/redis:v1

func ShortTypeToGCSDownloadUrls

func ShortTypeToGCSDownloadUrls(rp RegistryProvider, t string) ([]string, Registry, error)

ShortTypeToGCSDownloadUrls returns the download URLs for a short type name.

func ShortTypeToPackageDownloadURLs

func ShortTypeToPackageDownloadURLs(rp RegistryProvider, t string) ([]string, Registry, error)

ShortTypeToPackageDownloadURLs converts a github URL into downloadable URLs from github. Input must be of the type and is assumed to have been validated before this call: github.com/owner/repo/type for example: github.com/helm/charts/cassandra

type RegistryProvider

type RegistryProvider interface {
	GetRegistryByShortURL(URL string) (Registry, error)
	GetRegistryByName(registryName string) (Registry, error)
}

RegistryProvider is a factory for Registry instances.

func NewDefaultRegistryProvider

func NewDefaultRegistryProvider(cp common.CredentialProvider, rs common.RegistryService) RegistryProvider

NewDefaultRegistryProvider creates a default registry provider with the supplied credential.

func NewRegistryProvider

NewRegistryProvider creates a new registry provider using the supplied arguments.

type SecretsCredentialProvider

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

SecretsCredentialProvider provides credentials for registries from Kubernertes secrets.

func (*SecretsCredentialProvider) GetCredential

func (scp *SecretsCredentialProvider) GetCredential(name string) (*common.RegistryCredential, error)

GetCredential returns a credential by name.

func (*SecretsCredentialProvider) SetCredential

func (scp *SecretsCredentialProvider) SetCredential(name string, credential *common.RegistryCredential) error

SetCredential sets a credential by name.

type SemVer

type SemVer struct {
	Major uint
	Minor uint
	Patch uint
}

SemVer holds a semantic version as defined by semver.io.

func ParseSemVer

func ParseSemVer(version string) (SemVer, error)

ParseSemVer parses a semantic version string.

func (SemVer) IsZero

func (s SemVer) IsZero() bool

IsZero returns true if the semantic version is zero.

func (SemVer) String

func (s SemVer) String() string

SemVer conforms to the Stringer interface.

type TestURLAndError

type TestURLAndError struct {
	URL string
	Err error
}

TestURLAndError associates a URL with an error string for testing.

type Type

type Type struct {
	Collection string
	Name       string
	Version    SemVer
}

Type describes a type stored in a registry.

func NewType

func NewType(collection, name, version string) (Type, error)

NewType initializes a type

func NewTypeOrDie

func NewTypeOrDie(collection, name, version string) Type

NewTypeOrDie initializes a type and panics if initialization fails

func ParseType

func ParseType(ts string) (Type, error)

ParseType takes a registry type string and parses it into a *registry.Type. TODO: needs better validation that this is actually a registry type.

func (Type) GetVersion

func (t Type) GetVersion() string

GetVersion returns the type version with the letter "v" prepended.

func (*Type) SetVersion

func (t *Type) SetVersion(version string) error

SetVersion strips the letter "v" from version, if present, and sets the the version of the type to the result.

func (Type) String

func (t Type) String() string

Type conforms to the Stringer interface.

Jump to

Keyboard shortcuts

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