Documentation ¶
Overview ¶
Package utils implements common utility functions.
Index ¶
- func ClientCredentials(reg string) (*clientcredentials.Config, error)
- func ClientForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (remote.Client, error)
- func ExtractTarGz(gzipStream io.Reader, destDir string) ([]string, error)
- func GetCredentials(p *output.Printer) (username, password string, err error)
- func GetRegistryFromRef(ref string) (string, error)
- func Indexes(indexConfig *index.Config, path string) (*index.MergedIndexes, error)
- func Move(oldPath, newPath string) error
- func NameFromRef(ref string) (string, error)
- func ParseReference(mergedIndexes *index.MergedIndexes, name string) (string, error)
- func PullerForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (*ocipuller.Puller, error)
- func PusherForRegistry(ctx context.Context, plainHTTP bool, reg string, printer *output.Printer) (*ocipusher.Pusher, error)
- func WriteClientCredentials(registry string, cred *clientcredentials.Config) error
- type RegistryClientCredentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientCredentials ¶
func ClientCredentials(reg string) (*clientcredentials.Config, error)
ClientCredentials retrieves the client credentials for a specific registry.
func ClientForRegistry ¶
func ClientForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (remote.Client, error)
ClientForRegistry returns a new auth.Client for the given registry. It authenticates the client if credentials are found in the system.
func ExtractTarGz ¶
ExtractTarGz extracts a *.tar.gz compressed archive and moves its content to destDir. Returns a slice containing the full path of the extracted files.
func GetCredentials ¶
GetCredentials is used to retrieve username and password from standard input.
func GetRegistryFromRef ¶
GetRegistryFromRef extracts the registry from a ref string.
func Move ¶
Move moves oldPath file to to newPath file. It works also on different file system types.
func NameFromRef ¶
NameFromRef extracts the name of the artifact from a ref string.
func ParseReference ¶
func ParseReference(mergedIndexes *index.MergedIndexes, name string) (string, error)
ParseReference is a helper function that parse with the followig logic:
if name is the name of an artifact, it will use the merged index to compute its reference. The tag latest is always appended. e.g "cloudtrail" -> "ghcr.io/falcosecurity/plugins/cloudtrail:latest" if instead a tag or a digest is specified, the name will be used to look up into mergedIndexes, then the tag or digest will be appended. e.g "cloudtrail:0.5.1" -> "ghcr.io/falcosecurity/plugins/cloudtrail:0.5.1" e.g "cloudtrail@sha256:123abc..." -> "ghcr.io/falcosecurity/plugins/cloudtrail@sha256:123abc...
if name is a reference without tag or digest, tag latest is appended. e.g. "ghcr.io/falcosecurity/plugins/cloudtrail" -> "ghcr.io/falcosecurity/plugins/cloudtrail:latest"
if name is a complete reference, it will be returned as is.
func PullerForRegistry ¶
func PullerForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (*ocipuller.Puller, error)
PullerForRegistry returns a new ocipuller.Puller ready to be used for the given registry.
func PusherForRegistry ¶
func PusherForRegistry(ctx context.Context, plainHTTP bool, reg string, printer *output.Printer) (*ocipusher.Pusher, error)
PusherForRegistry returns ane ocipusher.Pusher ready to be used for the given registry.
func WriteClientCredentials ¶
func WriteClientCredentials(registry string, cred *clientcredentials.Config) error
WriteClientCredentials writes client credentials to config file.
Types ¶
type RegistryClientCredentials ¶
type RegistryClientCredentials map[string]clientcredentials.Config
RegistryClientCredentials is used to store registry:clientCrendetials key value. This is done to be in accordance with the way Docker stores credentials, so that users will be able to store only one credential per registry.