reglib

package module
v0.0.0-...-8415542 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: GPL-3.0 Imports: 21 Imported by: 1

README

reglib

golang docker registry lib

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG bool

DEBUG enables debug output

Functions

func ExtractTagNames

func ExtractTagNames(tags []Tag) []string

ExtractTagNames returns the names of the []Tags

func GetAuthFromFile

func GetAuthFromFile(registry string) (string, string)

GetAuthFromFile returns the username, password of that registry from the config file ($HOME/.docker/config.json)

func GetAuthTokens

func GetAuthTokens() (map[string]string, error)

GetAuthTokens from $HOME/.docker/config.json

func UnmarshalAuth

func UnmarshalAuth(auth string) (string, string)

UnmarshalAuth returns the username and password for that auth credential

Types

type Client

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

Client represents for a docker registry client

func (*Client) Host

func (c *Client) Host() string

func (*Client) Image

func (c *Client) Image(ctx context.Context, repo, tag string) (img *Image, err error)

func (*Client) Repos

func (c *Client) Repos(ctx context.Context,
	opts *ListRepoOptions) ([]Repository, error)

func (*Client) ReposChan

func (c *Client) ReposChan(ctx context.Context,
	opts *ListRepoOptions) (chan Repository, error)

func (*Client) Tags

func (c *Client) Tags(ctx context.Context, repo string,
	opts *ListTagOptions) ([]Tag, error)

type Image

type Image struct {
	V1 *v1.Manifest
	V2 *v2.Manifest
	// contains filtered or unexported fields
}

Image instance, includes the schemav1 and schemav2

func (*Image) Created

func (i *Image) Created() time.Time

Created returns the image's create time

func (*Image) Download

func (i *Image) Download(ctx context.Context, target string) error

Download this image

func (*Image) FSLayers

func (i *Image) FSLayers() []v1.FSLayer

FSLayers returns the fs layer info (schemav1)

func (*Image) FullName

func (i *Image) FullName() string

FullName return the image name and it's tag

func (*Image) History

func (i *Image) History() []ImageHistory

History converts the v1's history info to reglib's history struct

func (*Image) Layers

func (i *Image) Layers() []dis.Descriptor

Layers returns the layer info (schemav2)

func (*Image) Size

func (i *Image) Size() ImageSize

Size returns the image's size

type ImageHistory

type ImageHistory struct {
	Architecture string `json:"architecture,omitempty"`
	Config       struct {
		Hostname     string      `json:"Hostname,omitempty"`
		Domainname   string      `json:"Domainname,omitempty"`
		User         string      `json:"User,omitempty"`
		AttachStdin  bool        `json:"AttachStdin,omitempty"`
		AttachStdout bool        `json:"AttachStdout,omitempty"`
		AttachStderr bool        `json:"AttachStderr,omitempty"`
		Tty          bool        `json:"Tty,omitempty"`
		OpenStdin    bool        `json:"OpenStdin,omitempty"`
		StdinOnce    bool        `json:"StdinOnce,omitempty"`
		Env          []string    `json:"Env,omitempty"`
		Cmd          []string    `json:"Cmd,omitempty"`
		ArgsEscaped  bool        `json:"ArgsEscaped,omitempty"`
		Image        string      `json:"Image,omitempty"`
		Volumes      interface{} `json:"Volumes,omitempty"`
		WorkingDir   string      `json:"WorkingDir,omitempty"`
		Entrypoint   interface{} `json:"Entrypoint,omitempty"`
		OnBuild      interface{} `json:"OnBuild,omitempty"`
		Labels       interface{} `json:"Labels,omitempty"`
	} `json:"config,omitempty"`
	Container       string `json:"container,omitempty"`
	ContainerConfig struct {
		Hostname     string      `json:"Hostname,omitempty"`
		Domainname   string      `json:"Domainname,omitempty"`
		User         string      `json:"User,omitempty"`
		AttachStdin  bool        `json:"AttachStdin,omitempty"`
		AttachStdout bool        `json:"AttachStdout,omitempty"`
		AttachStderr bool        `json:"AttachStderr,omitempty"`
		Tty          bool        `json:"Tty,omitempty"`
		OpenStdin    bool        `json:"OpenStdin,omitempty"`
		StdinOnce    bool        `json:"StdinOnce,omitempty"`
		Env          []string    `json:"Env,omitempty"`
		Cmd          []string    `json:"Cmd,omitempty"`
		ArgsEscaped  bool        `json:"ArgsEscaped,omitempty"`
		Image        string      `json:"Image,omitempty"`
		Volumes      interface{} `json:"Volumes,omitempty"`
		WorkingDir   string      `json:"WorkingDir,omitempty"`
		Entrypoint   interface{} `json:"Entrypoint,omitempty"`
		OnBuild      interface{} `json:"OnBuild,omitempty"`
		Labels       struct {
		} `json:"Labels,omitempty"`
	} `json:"container_config,omitempty"`
	Created       time.Time `json:"created,omitempty"`
	DockerVersion string    `json:"docker_version,omitempty"`
	ID            string    `json:"id,omitempty"`
	Os            string    `json:"os,omitempty"`
	Parent        string    `json:"parent,omitempty"`
	Throwaway     bool      `json:"throwaway,omitempty"`
}

ImageHistory converted from json, thanks to https://mholt.github.io/json-to-go/

type ImageSize

type ImageSize int64

ImageSize is the size of the image

func (ImageSize) String

func (is ImageSize) String() string

type ListRepoOptions

type ListRepoOptions struct {
	WithTags   bool
	Start, End int
	Namespace  string
	Prefix     string
}

ListRepoOptions ...

type ListTagOptions

type ListTagOptions struct {
	WithManifest bool
	Prefix       string
}

ListTagOptions ...

type Registry

type Registry interface {
	// Repos list the repositories
	Repos(ctx context.Context, opts *ListRepoOptions) ([]Repository, error)
	// ReposChan returns a channel contains the repos
	ReposChan(ctx context.Context, opts *ListRepoOptions) (chan Repository, error)
	// Tags list the tags of the repository
	Tags(ctx context.Context, repo string, opts *ListTagOptions) ([]Tag, error)
	// Image get the image instance via the specific repo and tag
	Image(ctx context.Context, repo, tag string) (*Image, error)
	// return the registry's host (domain)
	Host() string
}

Registry is the interface of registry client

func New

func New(baseURL, user, pass string) (Registry, error)

New docker registry client

func NewFromConfigFile

func NewFromConfigFile(baseURL string) (Registry, error)

NewFromConfigFile ...

type Repository

type Repository struct {
	Name      string
	Namespace string
	// contains filtered or unexported fields
}

Repository is the instance of an repo

func (*Repository) Tags

func (r *Repository) Tags() ([]Tag, error)

Tags returns the repo's tags

type Tag

type Tag struct {
	Name     string
	FullName string
	RepoName string
	// contains filtered or unexported fields
}

Tag is the image's specific tag

func (*Tag) Image

func (t *Tag) Image() (*Image, error)

Image returns the repo:tag's manifest

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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