credentialconfig

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

Temporarily copied from a PR intended to be merged into kubernetes/kubernetes (https://github.com/kubernetes/kubernetes/pull/95775) to avoid depending on k8s-private code; imports of this package can be safely replaced and this directory removed once that PR is merged into a release of k8s that cloud-provider-gcp supports - please reach out to SIG Cloud Provider with any questions. The PR should be merged in v1.21.

Tracked by: https://github.com/kubernetes/cloud-provider-gcp/issues/173

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDockerConfigJSONPaths

func DefaultDockerConfigJSONPaths() []string

DefaultDockerConfigJSONPaths returns default search paths of .docker/config.json

func DefaultDockercfgPaths

func DefaultDockercfgPaths() []string

DefaultDockercfgPaths returns default search paths of .dockercfg

func GetPreferredDockercfgPath

func GetPreferredDockercfgPath() string

GetPreferredDockercfgPath get preferred docker config path

func ReadURL

func ReadURL(url string, client *http.Client, header *http.Header) (body []byte, err error)

ReadURL read contents from given url

func SetPreferredDockercfgPath

func SetPreferredDockercfgPath(path string)

SetPreferredDockercfgPath set preferred docker config path

Types

type CachingDockerConfigProvider

type CachingDockerConfigProvider struct {
	Provider DockerConfigProvider
	Lifetime time.Duration

	// ShouldCache is an optional function that returns true if the specific config should be cached.
	// If nil, all configs are treated as cacheable.
	ShouldCache func(DockerConfig) bool
	// contains filtered or unexported fields
}

CachingDockerConfigProvider implements DockerConfigProvider by composing with another DockerConfigProvider and caching the DockerConfig it provides for a pre-specified lifetime.

func (*CachingDockerConfigProvider) Enabled

func (d *CachingDockerConfigProvider) Enabled() bool

Enabled implements dockerConfigProvider

func (*CachingDockerConfigProvider) Provide

Provide implements dockerConfigProvider

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI. This config that represents the credentials that should be used when pulling images from specific image repositories.

func ReadDockerConfigFile

func ReadDockerConfigFile() (cfg DockerConfig, err error)

ReadDockerConfigFile read a docker config file from default path

func ReadDockerConfigFileFromBytes

func ReadDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error)

ReadDockerConfigFileFromBytes read a docker config file from the given bytes

func ReadDockerConfigFileFromURL

func ReadDockerConfigFileFromURL(url string, client *http.Client, header *http.Header) (cfg DockerConfig, err error)

ReadDockerConfigFileFromURL read a docker config file from the given url

func ReadDockerConfigJSONFile

func ReadDockerConfigJSONFile(searchPaths []string) (cfg DockerConfig, err error)

ReadDockerConfigJSONFile attempts to read a docker config.json file from the given paths. if searchPaths is empty, the default paths are used.

func ReadDockercfgFile

func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error)

ReadDockercfgFile attempts to read a legacy dockercfg file from the given paths. if searchPaths is empty, the default paths are used.

func ReadSpecificDockerConfigJSONFile

func ReadSpecificDockerConfigJSONFile(filePath string) (cfg DockerConfig, err error)

ReadSpecificDockerConfigJSONFile attempts to read docker configJSON from a given file path.

type DockerConfigEntry

type DockerConfigEntry struct {
	Username string
	Password string
	Email    string
	Provider DockerConfigProvider
}

DockerConfigEntry wraps a docker config as a entry

func (DockerConfigEntry) MarshalJSON

func (ident DockerConfigEntry) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*DockerConfigEntry) UnmarshalJSON

func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths DockerConfig `json:"auths"`
	// +optional
	HTTPHeaders map[string]string `json:"HttpHeaders,omitempty"`
}

DockerConfigJSON represents ~/.docker/config.json file info see https://github.com/docker/docker/pull/12009

type DockerConfigProvider

type DockerConfigProvider interface {
	// Enabled returns true if the config provider is enabled.
	// Implementations can be blocking - e.g. metadata server unavailable.
	Enabled() bool
	// Provide returns docker configuration.
	// Implementations can be blocking - e.g. metadata server unavailable.
	// The image is passed in as context in the event that the
	// implementation depends on information in the image name to return
	// credentials; implementations are safe to ignore the image.
	Provide(image string) DockerConfig
}

DockerConfigProvider is the interface that registered extensions implement to materialize 'dockercfg' credentials.

type HTTPError

type HTTPError struct {
	StatusCode int
	URL        string
}

HTTPError wraps a non-StatusOK error code as an error.

func (*HTTPError) Error

func (he *HTTPError) Error() string

Error implements error

Jump to

Keyboard shortcuts

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