registry

package
Version: v0.0.0-...-bb21d74 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: Apache-2.0 Imports: 30 Imported by: 5

Documentation

Index

Constants

View Source
const CONFIGFILE = ".dockercfg"

Where we store the config file

View Source
const INDEXSERVER = "https://index.docker.io/v1/"

Only used for user auth + account creation

Variables

View Source
var (
	ErrAlreadyExists         = errors.New("Image already exists")
	ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
)
View Source
var (
	ErrConfigFileMissing = errors.New("The Auth config file is missing")
)

Functions

func AddRequiredHeadersToRedirectedRequests

func AddRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error

func ExpandAndVerifyRegistryUrl

func ExpandAndVerifyRegistryUrl(hostname string) (string, error)

this method expands the registry name as used in the prefix of a repo to a full url. if it already is a url, there will be no change. The registry is pinged to test if it http or https

func HTTPRequestFactory

func HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory

func IndexServerAddress

func IndexServerAddress() string

func Login

func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, error)

try to register/login to the registry server

func ResolveRepositoryName

func ResolveRepositoryName(reposName string) (string, string, error)

Resolves a repository name to a hostname + name

func SaveConfig

func SaveConfig(configFile *ConfigFile) error

save the auth config

Types

type AuthConfig

type AuthConfig struct {
	Username      string `json:"username,omitempty"`
	Password      string `json:"password,omitempty"`
	Auth          string `json:"auth"`
	Email         string `json:"email"`
	ServerAddress string `json:"serveraddress,omitempty"`
}

type ConfigFile

type ConfigFile struct {
	Configs map[string]AuthConfig `json:"configs,omitempty"`
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(rootPath string) (*ConfigFile, error)

load up the auth config information and return values FIXME: use the internal golang config parser

func (*ConfigFile) ResolveAuthConfig

func (config *ConfigFile) ResolveAuthConfig(hostname string) AuthConfig

this method matches a auth configuration to a server address or a url

type ImgData

type ImgData struct {
	ID              string `json:"id"`
	Checksum        string `json:"checksum,omitempty"`
	ChecksumPayload string `json:"-"`
	Tag             string `json:",omitempty"`
}

type RegistryInfo

type RegistryInfo struct {
	Version    string `json:"version"`
	Standalone bool   `json:"standalone"`
}

type RepositoryData

type RepositoryData struct {
	ImgList   map[string]*ImgData
	Endpoints []string
	Tokens    []string
}

type SearchResult

type SearchResult struct {
	StarCount   int    `json:"star_count"`
	IsOfficial  bool   `json:"is_official"`
	Name        string `json:"name"`
	IsTrusted   bool   `json:"is_trusted"`
	Description string `json:"description"`
}

type SearchResults

type SearchResults struct {
	Query      string         `json:"query"`
	NumResults int            `json:"num_results"`
	Results    []SearchResult `json:"results"`
}

type Service

type Service struct {
}

Service exposes registry capabilities in the standard Engine interface. Once installed, it extends the engine with the following calls:

'auth': Authenticate against the public registry
'search': Search for images on the public registry
'pull': Download images from any registry (TODO)
'push': Upload images to any registry (TODO)

func NewService

func NewService() *Service

NewService returns a new instance of Service ready to be installed no an engine.

func (*Service) Auth

func (s *Service) Auth(job *engine.Job) engine.Status

Auth contacts the public registry with the provided credentials, and returns OK if authentication was sucessful. It can be used to verify the validity of a client's credentials.

func (*Service) Install

func (s *Service) Install(eng *engine.Engine) error

Install installs registry capabilities to eng.

func (*Service) Search

func (s *Service) Search(job *engine.Job) engine.Status

Search queries the public registry for images matching the specified search terms, and returns the results.

Argument syntax: search TERM

Option environment:

'authConfig': json-encoded credentials to authenticate against the registry.
	The search extends to images only accessible via the credentials.

'metaHeaders': extra HTTP headers to include in the request to the registry.
	The headers should be passed as a json-encoded dictionary.

Output:

Results are sent as a collection of structured messages (using engine.Table).
Each result is sent as a separate message.
Results are ordered by number of stars on the public registry.

type Session

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

func NewSession

func NewSession(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, indexEndpoint string, timeout bool) (r *Session, err error)

func (*Session) GetAuthConfig

func (r *Session) GetAuthConfig(withPasswd bool) *AuthConfig

func (*Session) GetRemoteHistory

func (r *Session) GetRemoteHistory(imgID, registry string, token []string) ([]string, error)

Retrieve the history of a given image from the Registry. Return a list of the parent's json (requested image included)

func (*Session) GetRemoteImageJSON

func (r *Session) GetRemoteImageJSON(imgID, registry string, token []string) ([]byte, int, error)

Retrieve an image from the Registry.

func (*Session) GetRemoteImageLayer

func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, imgSize int64) (io.ReadCloser, error)

func (*Session) GetRemoteTags

func (r *Session) GetRemoteTags(registries []string, repository string, token []string) (map[string]string, error)

func (*Session) GetRepositoryData

func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error)

func (*Session) LookupRemoteImage

func (r *Session) LookupRemoteImage(imgID, registry string, token []string) bool

Check if an image exists in the Registry TODO: This method should return the errors instead of masking them and returning false

func (*Session) PushImageChecksumRegistry

func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, token []string) error

func (*Session) PushImageJSONIndex

func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate bool, regs []string) (*RepositoryData, error)

func (*Session) PushImageJSONRegistry

func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error

Push a local image to the registry

func (*Session) PushImageLayerRegistry

func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string, jsonRaw []byte) (checksum string, checksumPayload string, err error)

func (*Session) PushRegistryTag

func (r *Session) PushRegistryTag(remote, revision, tag, registry string, token []string) error

push a tag on the registry. Remote has the format '<user>/<repo>

func (*Session) SearchRepositories

func (r *Session) SearchRepositories(term string) (*SearchResults, error)

type TimeoutType

type TimeoutType uint32
const (
	NoTimeout TimeoutType = iota
	ReceiveTimeout
	ConnectTimeout
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL