cli

package
v7.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *vault.ConfigFile) error
Example
f, err := os.CreateTemp("", "aws-config")
if err != nil {
	log.Fatal(err)
}
defer os.Remove(f.Name())

os.Setenv("AWS_CONFIG_FILE", f.Name())
os.Setenv("AWS_ACCESS_KEY_ID", "llamas")
os.Setenv("AWS_SECRET_ACCESS_KEY", "rock")
os.Setenv("AWS_VAULT_BACKEND", "file")
os.Setenv("AWS_VAULT_FILE_PASSPHRASE", "password")

defer os.Unsetenv("AWS_ACCESS_KEY_ID")
defer os.Unsetenv("AWS_SECRET_ACCESS_KEY")
defer os.Unsetenv("AWS_VAULT_BACKEND")
defer os.Unsetenv("AWS_VAULT_FILE_PASSPHRASE")

app := kingpin.New(`aws-vault`, ``)
ConfigureAddCommand(app, ConfigureGlobals(app))
kingpin.MustParse(app.Parse([]string{"add", "--debug", "--env", "foo"}))
Output:

Added credentials to profile "foo" in vault

func ClearCommand

func ClearCommand(input ClearCommandInput, awsConfigFile *vault.ConfigFile, keyring keyring.Keyring) error

func ConfigureAddCommand

func ConfigureAddCommand(app *kingpin.Application, a *AwsVault)

func ConfigureClearCommand

func ConfigureClearCommand(app *kingpin.Application, a *AwsVault)

func ConfigureExecCommand

func ConfigureExecCommand(app *kingpin.Application, a *AwsVault)

func ConfigureListCommand

func ConfigureListCommand(app *kingpin.Application, a *AwsVault)

func ConfigureLoginCommand

func ConfigureLoginCommand(app *kingpin.Application, a *AwsVault)

func ConfigureProxyCommand

func ConfigureProxyCommand(app *kingpin.Application, a *AwsVault)

func ConfigureRemoveCommand

func ConfigureRemoveCommand(app *kingpin.Application, a *AwsVault)

func ConfigureRotateCommand

func ConfigureRotateCommand(app *kingpin.Application, a *AwsVault)

func ExecCommand

func ExecCommand(input ExecCommandInput, f *vault.ConfigFile, keyring keyring.Keyring) error
Example
app := kingpin.New("aws-vault", "")
awsVault := ConfigureGlobals(app)
awsVault.keyringImpl = keyring.NewArrayKeyring([]keyring.Item{
	{Key: "llamas", Data: []byte(`{"AccessKeyID":"ABC","SecretAccessKey":"XYZ"}`)},
})
ConfigureExecCommand(app, awsVault)
kingpin.MustParse(app.Parse([]string{
	"--debug", "exec", "--no-session", "llamas", "--", "sh", "-c", "echo $AWS_ACCESS_KEY_ID",
}))
Output:

ABC

func ListCommand

func ListCommand(input ListCommandInput, awsConfigFile *vault.ConfigFile, keyring keyring.Keyring) (err error)
Example
app := kingpin.New("aws-vault", "")
awsVault := ConfigureGlobals(app)
awsVault.keyringImpl = keyring.NewArrayKeyring([]keyring.Item{
	{Key: "llamas", Data: []byte(`{"AccessKeyID":"ABC","SecretAccessKey":"XYZ"}`)},
})
ConfigureListCommand(app, awsVault)
kingpin.MustParse(app.Parse([]string{
	"list", "--credentials",
}))
Output:

llamas

func LoginCommand

func LoginCommand(input LoginCommandInput, f *vault.ConfigFile, keyring keyring.Keyring) error

func RemoveCommand

func RemoveCommand(input RemoveCommandInput, keyring keyring.Keyring) error

func RotateCommand

func RotateCommand(input RotateCommandInput, f *vault.ConfigFile, keyring keyring.Keyring) error

Types

type AddCommandInput

type AddCommandInput struct {
	ProfileName string
	FromEnv     bool
	AddConfig   bool
}

type AwsVault

type AwsVault struct {
	Debug          bool
	KeyringConfig  keyring.Config
	KeyringBackend string
	PromptDriver   string
	// contains filtered or unexported fields
}

func ConfigureGlobals

func ConfigureGlobals(app *kingpin.Application) *AwsVault

func (*AwsVault) AwsConfigFile

func (a *AwsVault) AwsConfigFile() (*vault.ConfigFile, error)

func (*AwsVault) Keyring

func (a *AwsVault) Keyring() (keyring.Keyring, error)

func (*AwsVault) MustGetProfileNames

func (a *AwsVault) MustGetProfileNames() []string

type ClearCommandInput

type ClearCommandInput struct {
	ProfileName string
}

type ExecCommandInput

type ExecCommandInput struct {
	ProfileName      string
	Command          string
	Args             []string
	StartEc2Server   bool
	StartEcsServer   bool
	Lazy             bool
	CredentialHelper bool
	Config           vault.Config
	SessionDuration  time.Duration
	NoSession        bool
	UseStdout        bool
}

type ListCommandInput

type ListCommandInput struct {
	OnlyProfiles    bool
	OnlySessions    bool
	OnlyCredentials bool
}

type LoginCommandInput

type LoginCommandInput struct {
	ProfileName     string
	UseStdout       bool
	Path            string
	Config          vault.Config
	SessionDuration time.Duration
	NoSession       bool
}

type RemoveCommandInput

type RemoveCommandInput struct {
	ProfileName  string
	SessionsOnly bool
	Force        bool
}

type RotateCommandInput

type RotateCommandInput struct {
	NoSession   bool
	ProfileName string
	Config      vault.Config
}

Jump to

Keyboard shortcuts

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