forked from toolshed/abra
chore: deps and vendor
This commit is contained in:
2
vendor/github.com/docker/cli/cli-plugins/manager/candidate.go
generated
vendored
2
vendor/github.com/docker/cli/cli-plugins/manager/candidate.go
generated
vendored
@ -17,5 +17,5 @@ func (c *candidate) Path() string {
|
||||
}
|
||||
|
||||
func (c *candidate) Metadata() ([]byte, error) {
|
||||
return exec.Command(c.path, MetadataSubcommandName).Output()
|
||||
return exec.Command(c.path, MetadataSubcommandName).Output() // #nosec G204 -- ignore "Subprocess launched with a potential tainted input or cmd arguments"
|
||||
}
|
||||
|
2
vendor/github.com/docker/cli/cli-plugins/manager/error.go
generated
vendored
2
vendor/github.com/docker/cli/cli-plugins/manager/error.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package manager
|
||||
|
||||
|
39
vendor/github.com/docker/cli/cli-plugins/manager/manager.go
generated
vendored
39
vendor/github.com/docker/cli/cli-plugins/manager/manager.go
generated
vendored
@ -75,10 +75,12 @@ func getPluginDirs(cfg *configfile.ConfigFile) ([]string, error) {
|
||||
return pluginDirs, nil
|
||||
}
|
||||
|
||||
func addPluginCandidatesFromDir(res map[string][]string, d string) error {
|
||||
func addPluginCandidatesFromDir(res map[string][]string, d string) {
|
||||
dentries, err := os.ReadDir(d)
|
||||
// Silently ignore any directories which we cannot list (e.g. due to
|
||||
// permissions or anything else) or which is not a directory
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
for _, dentry := range dentries {
|
||||
switch dentry.Type() & os.ModeType {
|
||||
@ -99,28 +101,15 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) error {
|
||||
}
|
||||
res[name] = append(res[name], filepath.Join(d, dentry.Name()))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// listPluginCandidates returns a map from plugin name to the list of (unvalidated) Candidates. The list is in descending order of priority.
|
||||
func listPluginCandidates(dirs []string) (map[string][]string, error) {
|
||||
func listPluginCandidates(dirs []string) map[string][]string {
|
||||
result := make(map[string][]string)
|
||||
for _, d := range dirs {
|
||||
// Silently ignore any directories which we cannot
|
||||
// Stat (e.g. due to permissions or anything else) or
|
||||
// which is not a directory.
|
||||
if fi, err := os.Stat(d); err != nil || !fi.IsDir() {
|
||||
continue
|
||||
}
|
||||
if err := addPluginCandidatesFromDir(result, d); err != nil {
|
||||
// Silently ignore paths which don't exist.
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
return nil, err // Or return partial result?
|
||||
}
|
||||
addPluginCandidatesFromDir(result, d)
|
||||
}
|
||||
return result, nil
|
||||
return result
|
||||
}
|
||||
|
||||
// GetPlugin returns a plugin on the system by its name
|
||||
@ -130,11 +119,7 @@ func GetPlugin(name string, dockerCli command.Cli, rootcmd *cobra.Command) (*Plu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
candidates, err := listPluginCandidates(pluginDirs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
candidates := listPluginCandidates(pluginDirs)
|
||||
if paths, ok := candidates[name]; ok {
|
||||
if len(paths) == 0 {
|
||||
return nil, errPluginNotFound(name)
|
||||
@ -160,10 +145,7 @@ func ListPlugins(dockerCli command.Cli, rootcmd *cobra.Command) ([]Plugin, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
candidates, err := listPluginCandidates(pluginDirs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
candidates := listPluginCandidates(pluginDirs)
|
||||
|
||||
var plugins []Plugin
|
||||
var mu sync.Mutex
|
||||
@ -240,7 +222,8 @@ func PluginRunCommand(dockerCli command.Cli, name string, rootcmd *cobra.Command
|
||||
// TODO: why are we not returning plugin.Err?
|
||||
return nil, errPluginNotFound(name)
|
||||
}
|
||||
cmd := exec.Command(plugin.Path, args...)
|
||||
cmd := exec.Command(plugin.Path, args...) // #nosec G204 -- ignore "Subprocess launched with a potential tainted input or cmd arguments"
|
||||
|
||||
// Using dockerCli.{In,Out,Err}() here results in a hang until something is input.
|
||||
// See: - https://github.com/golang/go/issues/10338
|
||||
// - https://github.com/golang/go/commit/d000e8742a173aa0659584aa01b7ba2834ba28ab
|
||||
|
2
vendor/github.com/docker/cli/cli-plugins/manager/plugin.go
generated
vendored
2
vendor/github.com/docker/cli/cli-plugins/manager/plugin.go
generated
vendored
@ -112,7 +112,7 @@ func (p *Plugin) RunHook(ctx context.Context, hookData HookPluginData) ([]byte,
|
||||
return nil, wrapAsPluginError(err, "failed to marshall hook data")
|
||||
}
|
||||
|
||||
pCmd := exec.CommandContext(ctx, p.Path, p.Name, HookSubcommandName, string(hDataBytes))
|
||||
pCmd := exec.CommandContext(ctx, p.Path, p.Name, HookSubcommandName, string(hDataBytes)) // #nosec G204 -- ignore "Subprocess launched with a potential tainted input or cmd arguments"
|
||||
pCmd.Env = os.Environ()
|
||||
pCmd.Env = append(pCmd.Env, ReexecEnvvar+"="+os.Args[0])
|
||||
hookCmdOutput, err := pCmd.Output()
|
||||
|
2
vendor/github.com/docker/cli/cli/command/cli.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/cli.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package command
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/context.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/context.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package command
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/defaultcontextstore.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/defaultcontextstore.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package command
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/formatter/container.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/formatter/container.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package formatter
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/formatter/custom.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/formatter/custom.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package formatter
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/formatter/formatter.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/formatter/formatter.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package formatter
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/formatter/reflect.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/formatter/reflect.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package formatter
|
||||
|
||||
|
77
vendor/github.com/docker/cli/cli/command/registry.go
generated
vendored
77
vendor/github.com/docker/cli/cli/command/registry.go
generated
vendored
@ -19,20 +19,24 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const patSuggest = "You can log in with your password or a Personal Access " +
|
||||
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
|
||||
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
|
||||
const (
|
||||
registerSuggest = "Log in with your Docker ID or email address to push and pull images from Docker Hub. " +
|
||||
"If you don't have a Docker ID, head over to https://hub.docker.com/ to create one."
|
||||
patSuggest = "You can log in with your password or a Personal Access " +
|
||||
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
|
||||
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
|
||||
)
|
||||
|
||||
// RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
|
||||
// for the given command.
|
||||
func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) types.RequestPrivilegeFunc {
|
||||
return func(ctx context.Context) (string, error) {
|
||||
fmt.Fprintf(cli.Out(), "\nLogin prior to %s:\n", cmdName)
|
||||
_, _ = fmt.Fprintf(cli.Out(), "\nLogin prior to %s:\n", cmdName)
|
||||
indexServer := registry.GetAuthConfigKey(index)
|
||||
isDefaultRegistry := indexServer == registry.IndexServer
|
||||
authConfig, err := GetDefaultAuthConfig(cli.ConfigFile(), true, indexServer, isDefaultRegistry)
|
||||
if err != nil {
|
||||
fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", indexServer, err)
|
||||
_, _ = fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", indexServer, err)
|
||||
}
|
||||
|
||||
select {
|
||||
@ -87,7 +91,8 @@ func GetDefaultAuthConfig(cfg *configfile.ConfigFile, checkCredStore bool, serve
|
||||
}
|
||||
|
||||
// ConfigureAuth handles prompting of user's username and password if needed.
|
||||
// Deprecated: use PromptUserForCredentials instead.
|
||||
//
|
||||
// Deprecated: use [PromptUserForCredentials] instead.
|
||||
func ConfigureAuth(ctx context.Context, cli Cli, flUser, flPassword string, authConfig *registrytypes.AuthConfig, _ bool) error {
|
||||
defaultUsername := authConfig.Username
|
||||
serverAddress := authConfig.ServerAddress
|
||||
@ -111,7 +116,7 @@ func ConfigureAuth(ctx context.Context, cli Cli, flUser, flPassword string, auth
|
||||
// If defaultUsername is not empty, the username prompt includes that username
|
||||
// and the user can hit enter without inputting a username to use that default
|
||||
// username.
|
||||
func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword, defaultUsername, serverAddress string) (authConfig registrytypes.AuthConfig, err error) {
|
||||
func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword, defaultUsername, serverAddress string) (registrytypes.AuthConfig, error) {
|
||||
// On Windows, force the use of the regular OS stdin stream.
|
||||
//
|
||||
// See:
|
||||
@ -124,57 +129,71 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
|
||||
cli.SetIn(streams.NewIn(os.Stdin))
|
||||
}
|
||||
|
||||
isDefaultRegistry := serverAddress == registry.IndexServer
|
||||
defaultUsername = strings.TrimSpace(defaultUsername)
|
||||
|
||||
if argUser = strings.TrimSpace(argUser); argUser == "" {
|
||||
if isDefaultRegistry {
|
||||
// if this is a default registry (docker hub), then display the following message.
|
||||
fmt.Fprintln(cli.Out(), "Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.")
|
||||
argUser = strings.TrimSpace(argUser)
|
||||
if argUser == "" {
|
||||
if serverAddress == registry.IndexServer {
|
||||
// When signing in to the default (Docker Hub) registry, we display
|
||||
// hints for creating an account, and (if hints are enabled), using
|
||||
// a token instead of a password.
|
||||
_, _ = fmt.Fprintln(cli.Out(), registerSuggest)
|
||||
if hints.Enabled() {
|
||||
fmt.Fprintln(cli.Out(), patSuggest)
|
||||
fmt.Fprintln(cli.Out())
|
||||
_, _ = fmt.Fprintln(cli.Out(), patSuggest)
|
||||
_, _ = fmt.Fprintln(cli.Out())
|
||||
}
|
||||
}
|
||||
|
||||
var prompt string
|
||||
defaultUsername = strings.TrimSpace(defaultUsername)
|
||||
if defaultUsername == "" {
|
||||
prompt = "Username: "
|
||||
} else {
|
||||
prompt = fmt.Sprintf("Username (%s): ", defaultUsername)
|
||||
}
|
||||
|
||||
var err error
|
||||
argUser, err = PromptForInput(ctx, cli.In(), cli.Out(), prompt)
|
||||
if err != nil {
|
||||
return authConfig, err
|
||||
return registrytypes.AuthConfig{}, err
|
||||
}
|
||||
if argUser == "" {
|
||||
argUser = defaultUsername
|
||||
}
|
||||
if argUser == "" {
|
||||
return registrytypes.AuthConfig{}, errors.Errorf("Error: Non-null Username Required")
|
||||
}
|
||||
}
|
||||
if argUser == "" {
|
||||
return authConfig, errors.Errorf("Error: Non-null Username Required")
|
||||
}
|
||||
|
||||
argPassword = strings.TrimSpace(argPassword)
|
||||
if argPassword == "" {
|
||||
restoreInput, err := DisableInputEcho(cli.In())
|
||||
if err != nil {
|
||||
return authConfig, err
|
||||
return registrytypes.AuthConfig{}, err
|
||||
}
|
||||
defer restoreInput()
|
||||
defer func() {
|
||||
if err := restoreInput(); err != nil {
|
||||
// TODO(thaJeztah): we should consider printing instructions how
|
||||
// to restore this manually (other than restarting the shell).
|
||||
// e.g., 'run stty echo' when in a Linux or macOS shell, but
|
||||
// PowerShell and CMD.exe may need different instructions.
|
||||
_, _ = fmt.Fprintln(cli.Err(), "Error: failed to restore terminal state to echo input:", err)
|
||||
}
|
||||
}()
|
||||
|
||||
argPassword, err = PromptForInput(ctx, cli.In(), cli.Out(), "Password: ")
|
||||
if err != nil {
|
||||
return authConfig, err
|
||||
return registrytypes.AuthConfig{}, err
|
||||
}
|
||||
fmt.Fprint(cli.Out(), "\n")
|
||||
_, _ = fmt.Fprintln(cli.Out())
|
||||
if argPassword == "" {
|
||||
return authConfig, errors.Errorf("Error: Password Required")
|
||||
return registrytypes.AuthConfig{}, errors.Errorf("Error: Password Required")
|
||||
}
|
||||
}
|
||||
|
||||
authConfig.Username = argUser
|
||||
authConfig.Password = argPassword
|
||||
authConfig.ServerAddress = serverAddress
|
||||
return authConfig, nil
|
||||
return registrytypes.AuthConfig{
|
||||
Username: argUser,
|
||||
Password: argPassword,
|
||||
ServerAddress: serverAddress,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RetrieveAuthTokenFromImage retrieves an encoded auth token given a complete
|
||||
|
4
vendor/github.com/docker/cli/cli/command/telemetry_docker.go
generated
vendored
4
vendor/github.com/docker/cli/cli/command/telemetry_docker.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(jsternberg): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.22
|
||||
|
||||
package command
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/command/utils.go
generated
vendored
2
vendor/github.com/docker/cli/cli/command/utils.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package command
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package interpolation
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/loader/interpolate.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/loader/interpolate.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package loader
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/loader/loader.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/loader/loader.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package loader
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/loader/merge.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/loader/merge.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package loader
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/schema/schema.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/schema/schema.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package schema
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/template/template.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/template/template.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package template
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/compose/types/types.go
generated
vendored
2
vendor/github.com/docker/cli/cli/compose/types/types.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package types
|
||||
|
||||
|
14
vendor/github.com/docker/cli/cli/config/credentials/file_store.go
generated
vendored
14
vendor/github.com/docker/cli/cli/config/credentials/file_store.go
generated
vendored
@ -25,8 +25,13 @@ func NewFileStore(file store) Store {
|
||||
return &fileStore{file: file}
|
||||
}
|
||||
|
||||
// Erase removes the given credentials from the file store.
|
||||
// Erase removes the given credentials from the file store.This function is
|
||||
// idempotent and does not update the file if credentials did not change.
|
||||
func (c *fileStore) Erase(serverAddress string) error {
|
||||
if _, exists := c.file.GetAuthConfigs()[serverAddress]; !exists {
|
||||
// nothing to do; no credentials found for the given serverAddress
|
||||
return nil
|
||||
}
|
||||
delete(c.file.GetAuthConfigs(), serverAddress)
|
||||
return c.file.Save()
|
||||
}
|
||||
@ -52,9 +57,14 @@ func (c *fileStore) GetAll() (map[string]types.AuthConfig, error) {
|
||||
return c.file.GetAuthConfigs(), nil
|
||||
}
|
||||
|
||||
// Store saves the given credentials in the file store.
|
||||
// Store saves the given credentials in the file store. This function is
|
||||
// idempotent and does not update the file if credentials did not change.
|
||||
func (c *fileStore) Store(authConfig types.AuthConfig) error {
|
||||
authConfigs := c.file.GetAuthConfigs()
|
||||
if oldAuthConfig, ok := authConfigs[authConfig.ServerAddress]; ok && oldAuthConfig == authConfig {
|
||||
// Credentials didn't change, so skip updating the configuration file.
|
||||
return nil
|
||||
}
|
||||
authConfigs[authConfig.ServerAddress] = authConfig
|
||||
return c.file.Save()
|
||||
}
|
||||
|
2
vendor/github.com/docker/cli/cli/context/store/metadatastore.go
generated
vendored
2
vendor/github.com/docker/cli/cli/context/store/metadatastore.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package store
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/context/store/store.go
generated
vendored
2
vendor/github.com/docker/cli/cli/context/store/store.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package store
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/context/store/storeconfig.go
generated
vendored
2
vendor/github.com/docker/cli/cli/context/store/storeconfig.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package store
|
||||
|
||||
|
2
vendor/github.com/docker/cli/cli/error.go
generated
vendored
2
vendor/github.com/docker/cli/cli/error.go
generated
vendored
@ -8,6 +8,8 @@ import (
|
||||
// Errors is a list of errors.
|
||||
// Useful in a loop if you don't want to return the error right away and you want to display after the loop,
|
||||
// all the errors that happened during the loop.
|
||||
//
|
||||
// Deprecated: use [errors.Join] instead; will be removed in the next release.
|
||||
type Errors []error
|
||||
|
||||
func (errList Errors) Error() string {
|
||||
|
2
vendor/github.com/docker/cli/cli/required.go
generated
vendored
2
vendor/github.com/docker/cli/cli/required.go
generated
vendored
@ -14,7 +14,7 @@ func NoArgs(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if cmd.HasSubCommands() {
|
||||
return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
|
||||
return errors.New("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
|
||||
}
|
||||
|
||||
return errors.Errorf(
|
||||
|
1
vendor/github.com/docker/cli/cli/trust/trust.go
generated
vendored
1
vendor/github.com/docker/cli/cli/trust/trust.go
generated
vendored
@ -157,7 +157,6 @@ func GetNotaryRepository(in io.Reader, out io.Writer, userAgent string, repoInfo
|
||||
scope := auth.RepositoryScope{
|
||||
Repository: repoInfo.Name.Name(),
|
||||
Actions: actions,
|
||||
Class: repoInfo.Class, // TODO(thaJeztah): Class is no longer needed for plugins and can likely be removed; see https://github.com/docker/cli/pull/4114#discussion_r1145430825
|
||||
}
|
||||
creds := simpleCredentialStore{auth: *authConfig}
|
||||
tokenHandlerOptions := auth.TokenHandlerOptions{
|
||||
|
4
vendor/github.com/docker/cli/opts/envfile.go
generated
vendored
4
vendor/github.com/docker/cli/opts/envfile.go
generated
vendored
@ -2,6 +2,8 @@ package opts
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/docker/cli/pkg/kvfile"
|
||||
)
|
||||
|
||||
// ParseEnvFile reads a file with environment variables enumerated by lines
|
||||
@ -18,5 +20,5 @@ import (
|
||||
// environment variables, that's why we just strip leading whitespace and
|
||||
// nothing more.
|
||||
func ParseEnvFile(filename string) ([]string, error) {
|
||||
return parseKeyValueFile(filename, os.LookupEnv)
|
||||
return kvfile.Parse(filename, os.LookupEnv)
|
||||
}
|
||||
|
76
vendor/github.com/docker/cli/opts/file.go
generated
vendored
76
vendor/github.com/docker/cli/opts/file.go
generated
vendored
@ -1,76 +0,0 @@
|
||||
package opts
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
|
||||
// ErrBadKey typed error for bad environment variable
|
||||
type ErrBadKey struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func (e ErrBadKey) Error() string {
|
||||
return "poorly formatted environment: " + e.msg
|
||||
}
|
||||
|
||||
func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([]string, error) {
|
||||
fh, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
lines := []string{}
|
||||
scanner := bufio.NewScanner(fh)
|
||||
currentLine := 0
|
||||
utf8bom := []byte{0xEF, 0xBB, 0xBF}
|
||||
for scanner.Scan() {
|
||||
scannedBytes := scanner.Bytes()
|
||||
if !utf8.Valid(scannedBytes) {
|
||||
return []string{}, fmt.Errorf("env file %s contains invalid utf8 bytes at line %d: %v", filename, currentLine+1, scannedBytes)
|
||||
}
|
||||
// We trim UTF8 BOM
|
||||
if currentLine == 0 {
|
||||
scannedBytes = bytes.TrimPrefix(scannedBytes, utf8bom)
|
||||
}
|
||||
// trim the line from all leading whitespace first
|
||||
line := strings.TrimLeftFunc(string(scannedBytes), unicode.IsSpace)
|
||||
currentLine++
|
||||
// line is not empty, and not starting with '#'
|
||||
if len(line) > 0 && !strings.HasPrefix(line, "#") {
|
||||
variable, value, hasValue := strings.Cut(line, "=")
|
||||
|
||||
// trim the front of a variable, but nothing else
|
||||
variable = strings.TrimLeft(variable, whiteSpaces)
|
||||
if strings.ContainsAny(variable, whiteSpaces) {
|
||||
return []string{}, ErrBadKey{fmt.Sprintf("variable '%s' contains whitespaces", variable)}
|
||||
}
|
||||
if len(variable) == 0 {
|
||||
return []string{}, ErrBadKey{fmt.Sprintf("no variable name on line '%s'", line)}
|
||||
}
|
||||
|
||||
if hasValue {
|
||||
// pass the value through, no trimming
|
||||
lines = append(lines, variable+"="+value)
|
||||
} else {
|
||||
var present bool
|
||||
if emptyFn != nil {
|
||||
value, present = emptyFn(line)
|
||||
}
|
||||
if present {
|
||||
// if only a pass-through variable is given, clean it up.
|
||||
lines = append(lines, strings.TrimSpace(variable)+"="+value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines, scanner.Err()
|
||||
}
|
2
vendor/github.com/docker/cli/opts/opts.go
generated
vendored
2
vendor/github.com/docker/cli/opts/opts.go
generated
vendored
@ -266,6 +266,8 @@ func validateDomain(val string) (string, error) {
|
||||
return "", fmt.Errorf("%s is not a valid domain", val)
|
||||
}
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
|
||||
// ValidateLabel validates that the specified string is a valid label, and returns it.
|
||||
//
|
||||
// Labels are in the form of key=value; key must be a non-empty string, and not
|
||||
|
3
vendor/github.com/docker/cli/opts/parse.go
generated
vendored
3
vendor/github.com/docker/cli/opts/parse.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/pkg/kvfile"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
@ -25,7 +26,7 @@ func ReadKVEnvStrings(files []string, override []string) ([]string, error) {
|
||||
func readKVStrings(files []string, override []string, emptyFn func(string) (string, bool)) ([]string, error) {
|
||||
var variables []string
|
||||
for _, ef := range files {
|
||||
parsedVars, err := parseKeyValueFile(ef, emptyFn)
|
||||
parsedVars, err := kvfile.Parse(ef, emptyFn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
130
vendor/github.com/docker/cli/pkg/kvfile/kvfile.go
generated
vendored
Normal file
130
vendor/github.com/docker/cli/pkg/kvfile/kvfile.go
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
// Package kvfile provides utilities to parse line-delimited key/value files
|
||||
// such as used for label-files and env-files.
|
||||
//
|
||||
// # File format
|
||||
//
|
||||
// key/value files use the following syntax:
|
||||
//
|
||||
// - File must be valid UTF-8.
|
||||
// - BOM headers are removed.
|
||||
// - Leading whitespace is removed for each line.
|
||||
// - Lines starting with "#" are ignored.
|
||||
// - Empty lines are ignored.
|
||||
// - Key/Value pairs are provided as "KEY[=<VALUE>]".
|
||||
// - Maximum line-length is limited to [bufio.MaxScanTokenSize].
|
||||
//
|
||||
// # Interpolation, substitution, and escaping
|
||||
//
|
||||
// Both keys and values are used as-is; no interpolation, substitution or
|
||||
// escaping is supported, and quotes are considered part of the key or value.
|
||||
// Whitespace in values (including leading and trailing) is preserved. Given
|
||||
// that the file format is line-delimited, neither key, nor value, can contain
|
||||
// newlines.
|
||||
//
|
||||
// # Key/Value pairs
|
||||
//
|
||||
// Key/Value pairs take the following format:
|
||||
//
|
||||
// KEY[=<VALUE>]
|
||||
//
|
||||
// KEY is required and may not contain whitespaces or NUL characters. Any
|
||||
// other character (except for the "=" delimiter) are accepted, but it is
|
||||
// recommended to use a subset of the POSIX portable character set, as
|
||||
// outlined in [Environment Variables].
|
||||
//
|
||||
// VALUE is optional, but may be empty. If no value is provided (i.e., no
|
||||
// equal sign ("=") is present), the KEY is omitted in the result, but some
|
||||
// functions accept a lookup-function to provide a default value for the
|
||||
// given key.
|
||||
//
|
||||
// [Environment Variables]: https://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
|
||||
package kvfile
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Parse parses a line-delimited key/value pairs separated by equal sign.
|
||||
// It accepts a lookupFn to lookup default values for keys that do not define
|
||||
// a value. An error is produced if parsing failed, the content contains invalid
|
||||
// UTF-8 characters, or a key contains whitespaces.
|
||||
func Parse(filename string, lookupFn func(key string) (value string, found bool)) ([]string, error) {
|
||||
fh, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
out, err := parseKeyValueFile(fh, lookupFn)
|
||||
_ = fh.Close()
|
||||
if err != nil {
|
||||
return []string{}, fmt.Errorf("invalid env file (%s): %v", filename, err)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ParseFromReader parses a line-delimited key/value pairs separated by equal sign.
|
||||
// It accepts a lookupFn to lookup default values for keys that do not define
|
||||
// a value. An error is produced if parsing failed, the content contains invalid
|
||||
// UTF-8 characters, or a key contains whitespaces.
|
||||
func ParseFromReader(r io.Reader, lookupFn func(key string) (value string, found bool)) ([]string, error) {
|
||||
return parseKeyValueFile(r, lookupFn)
|
||||
}
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
|
||||
func parseKeyValueFile(r io.Reader, lookupFn func(string) (string, bool)) ([]string, error) {
|
||||
lines := []string{}
|
||||
scanner := bufio.NewScanner(r)
|
||||
utf8bom := []byte{0xEF, 0xBB, 0xBF}
|
||||
for currentLine := 1; scanner.Scan(); currentLine++ {
|
||||
scannedBytes := scanner.Bytes()
|
||||
if !utf8.Valid(scannedBytes) {
|
||||
return []string{}, fmt.Errorf("invalid utf8 bytes at line %d: %v", currentLine, scannedBytes)
|
||||
}
|
||||
// We trim UTF8 BOM
|
||||
if currentLine == 1 {
|
||||
scannedBytes = bytes.TrimPrefix(scannedBytes, utf8bom)
|
||||
}
|
||||
// trim the line from all leading whitespace first. trailing whitespace
|
||||
// is part of the value, and is kept unmodified.
|
||||
line := strings.TrimLeftFunc(string(scannedBytes), unicode.IsSpace)
|
||||
|
||||
if len(line) == 0 || line[0] == '#' {
|
||||
// skip empty lines and comments (lines starting with '#')
|
||||
continue
|
||||
}
|
||||
|
||||
key, _, hasValue := strings.Cut(line, "=")
|
||||
if len(key) == 0 {
|
||||
return []string{}, fmt.Errorf("no variable name on line '%s'", line)
|
||||
}
|
||||
|
||||
// leading whitespace was already removed from the line, but
|
||||
// variables are not allowed to contain whitespace or have
|
||||
// trailing whitespace.
|
||||
if strings.ContainsAny(key, whiteSpaces) {
|
||||
return []string{}, fmt.Errorf("variable '%s' contains whitespaces", key)
|
||||
}
|
||||
|
||||
if hasValue {
|
||||
// key/value pair is valid and has a value; add the line as-is.
|
||||
lines = append(lines, line)
|
||||
continue
|
||||
}
|
||||
|
||||
if lookupFn != nil {
|
||||
// No value given; try to look up the value. The value may be
|
||||
// empty but if no value is found, the key is omitted.
|
||||
if value, found := lookupFn(line); found {
|
||||
lines = append(lines, key+"="+value)
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines, scanner.Err()
|
||||
}
|
2
vendor/github.com/docker/cli/templates/templates.go
generated
vendored
2
vendor/github.com/docker/cli/templates/templates.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
||||
//go:build go1.21
|
||||
//go:build go1.22
|
||||
|
||||
package templates
|
||||
|
||||
|
Reference in New Issue
Block a user