cli

package
v5.5.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 25 Imported by: 0

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 := ioutil.TempFile("", "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 ConfigureAddCommand

func ConfigureAddCommand(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 ConfigureRemoveCommand

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

func ConfigureRotateCommand

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

func ConfigureServerCommand

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

func ExecCommand

func ExecCommand(input ExecCommandInput, configLoader *vault.ConfigLoader, 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 LoginCommand

func LoginCommand(input LoginCommandInput, configLoader *vault.ConfigLoader, keyring keyring.Keyring) error

func LsCommand

func LsCommand(input LsCommandInput, 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 RemoveCommand

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

func RotateCommand

func RotateCommand(input RotateCommandInput, configLoader *vault.ConfigLoader, keyring keyring.Keyring) error

Types

type AddCommandInput

type AddCommandInput struct {
	ProfileName string
	FromEnv     bool
	AddConfig   bool
}

type AwsCredentialHelperData

type AwsCredentialHelperData struct {
	Version         int    `json:"Version"`
	AccessKeyID     string `json:"AccessKeyId"`
	SecretAccessKey string `json:"SecretAccessKey"`
	SessionToken    string `json:"SessionToken,omitempty"`
	Expiration      string `json:"Expiration,omitempty"`
}

AwsCredentialHelperData is metadata for AWS CLI credential process See https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#sourcing-credentials-from-external-processes

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) ConfigLoader

func (a *AwsVault) ConfigLoader() (*vault.ConfigLoader, error)

func (*AwsVault) Keyring

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

func (*AwsVault) MustGetProfileNames

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

type ExecCommandInput

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

type LoginCommandInput

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

type LsCommandInput

type LsCommandInput struct {
	OnlyProfiles    bool
	OnlySessions    bool
	OnlyCredentials bool
}

type RemoveCommandInput

type RemoveCommandInput struct {
	ProfileName  string
	SessionsOnly 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