google

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 18 Imported by: 84

README

google

GoDoc

The google package provides:

  • Some google-specific authentication methods.
  • Some GCR-specific listing methods.

Documentation

Overview

Package google provides facilities for listing images in gcr.io.

Index

Constants

This section is empty.

Variables

View Source
var GetGcloudCmd = func() *exec.Cmd {

	return exec.Command("gcloud", "config", "config-helper", "--force-auth-refresh", "--format=json(credential)")
}

GetGcloudCmd is exposed so we can test this.

View Source
var Keychain authn.Keychain = &googleKeychain{}

Keychain exports an instance of the google Keychain.

Functions

func NewEnvAuthenticator

func NewEnvAuthenticator() (authn.Authenticator, error)

NewEnvAuthenticator returns an authn.Authenticator that generates access tokens from the environment we're running in.

See: https://godoc.org/golang.org/x/oauth2/google#FindDefaultCredentials

func NewGcloudAuthenticator

func NewGcloudAuthenticator() (authn.Authenticator, error)

NewGcloudAuthenticator returns an oauth2.TokenSource that generates access tokens by shelling out to the gcloud sdk.

func NewJSONKeyAuthenticator

func NewJSONKeyAuthenticator(serviceAccountJSON string) authn.Authenticator

NewJSONKeyAuthenticator returns a Basic authenticator which uses Service Account as a way of authenticating with Google Container Registry. More information: https://cloud.google.com/container-registry/docs/advanced-authentication#json_key_file

func NewTokenAuthenticator

func NewTokenAuthenticator(serviceAccountJSON string, scope string) (authn.Authenticator, error)

NewTokenAuthenticator returns an oauth2.TokenSource that generates access tokens by using the Google SDK to produce JWT tokens from a Service Account. More information: https://godoc.org/golang.org/x/oauth2/google#JWTAccessTokenSourceFromJSON

func NewTokenSourceAuthenticator added in v0.2.0

func NewTokenSourceAuthenticator(ts oauth2.TokenSource) authn.Authenticator

NewTokenSourceAuthenticator converts an oauth2.TokenSource into an authn.Authenticator.

func Walk

func Walk(root name.Repository, walkFn WalkFunc, options ...ListerOption) error

Walk recursively descends repositories, calling walkFn.

Types

type ListerOption

type ListerOption func(*lister) error

ListerOption is a functional option for List and Walk. TODO: Can we somehow reuse the remote options here?

func WithAuth

func WithAuth(auth authn.Authenticator) ListerOption

WithAuth is a functional option for overriding the default authenticator on a remote image

func WithAuthFromKeychain

func WithAuthFromKeychain(keys authn.Keychain) ListerOption

WithAuthFromKeychain is a functional option for overriding the default authenticator on a remote image using an authn.Keychain

func WithContext added in v0.1.4

func WithContext(ctx context.Context) ListerOption

WithContext is a functional option for overriding the default context.Context for HTTP request to list remote images

func WithTransport

func WithTransport(t http.RoundTripper) ListerOption

WithTransport is a functional option for overriding the default transport on a remote image

func WithUserAgent added in v0.4.0

func WithUserAgent(ua string) ListerOption

WithUserAgent adds the given string to the User-Agent header for any HTTP requests. This header will also include "go-containerregistry/${version}".

If you want to completely overwrite the User-Agent header, use WithTransport.

type ManifestInfo

type ManifestInfo struct {
	Size      uint64    `json:"imageSizeBytes"`
	MediaType string    `json:"mediaType"`
	Created   time.Time `json:"timeCreatedMs"`
	Uploaded  time.Time `json:"timeUploadedMs"`
	Tags      []string  `json:"tag"`
}

ManifestInfo is a Manifests entry is the output of List and Walk.

func (ManifestInfo) MarshalJSON

func (m ManifestInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*ManifestInfo) UnmarshalJSON

func (m *ManifestInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Tags

type Tags struct {
	Children  []string                `json:"child"`
	Manifests map[string]ManifestInfo `json:"manifest"`
	Name      string                  `json:"name"`
	Tags      []string                `json:"tags"`
}

Tags is the result of List and Walk.

func List

func List(repo name.Repository, options ...ListerOption) (*Tags, error)

List calls /tags/list for the given repository.

type WalkFunc

type WalkFunc func(repo name.Repository, tags *Tags, err error) error

WalkFunc is the type of the function called for each repository visited by Walk. This implements a similar API to filepath.Walk.

The repo argument contains the argument to Walk as a prefix; that is, if Walk is called with "gcr.io/foo", which is a repository containing the repository "bar", the walk function will be called with argument "gcr.io/foo/bar". The tags and error arguments are the result of calling List on repo.

TODO: Do we want a SkipDir error, as in filepath.WalkFunc?

Jump to

Keyboard shortcuts

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