registry

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(format string, args ...interface{})

Log passes log messages to the logging package.

func Quiet

func Quiet(format string, args ...interface{})

Quiet discards logs silently.

Types

type BasicTransport

type BasicTransport struct {
	Transport http.RoundTripper
	URL       string
	Username  string
	Password  string
}

BasicTransport defines the data structure for authentication via basic auth.

func (*BasicTransport) RoundTrip

func (t *BasicTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip defines the round tripper for basic auth transport.

type ErrorTransport

type ErrorTransport struct {
	Transport http.RoundTripper
}

ErrorTransport defines the data structure for returning errors from the round tripper.

func (*ErrorTransport) RoundTrip

func (t *ErrorTransport) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip defines the round tripper for the error transport.

type LogfCallback

type LogfCallback func(format string, args ...interface{})

LogfCallback is the callback for formatting logs.

type Opt

type Opt struct {
	Domain  string
	NonSSL  bool
	Timeout time.Duration
	Headers map[string]string
}

Opt holds the options for a new registry.

type Registry

type Registry struct {
	URL      string
	Domain   string
	Username string
	Password string
	Client   *http.Client
	Logf     LogfCallback
	Opt      Opt
}

Registry defines the client for retrieving information from the registry API.

func New

func New(ctx context.Context, auth types.AuthConfig, opt Opt) (*Registry, error)

New creates a new Registry struct with the given URL and credentials.

func (*Registry) GetJSON

func (r *Registry) GetJSON(ctx context.Context, url string, response interface{}) (http.Header, error)

GetJSON

func (*Registry) Headers

func (r *Registry) Headers(ctx context.Context, uri string) (map[string]string, error)

Headers returns the authorization headers for a specific uri.

func (*Registry) Token

func (r *Registry) Token(ctx context.Context, url string) (string, error)

Token returns the required token for the specific resource url. If the registry requires basic authentication, this function returns ErrBasicAuth.

func (*Registry) Url

func (r *Registry) Url(pathTemplate string, args ...interface{}) string

Url : url returns a registry URL with the passed arguements concatenated.

type TokenTransport

type TokenTransport struct {
	Transport http.RoundTripper
	Username  string
	Password  string
}

TokenTransport defines the data structure for authentication via tokens.

func (*TokenTransport) RoundTrip

func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip defines the round tripper for token transport.

Jump to

Keyboard shortcuts

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