Skip to content

Commit

Permalink
Fix ini output to match credentials file
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Mar 20, 2023
1 parent cec0d62 commit a4f5e3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func printINI(credsProvider aws.CredentialsProvider, profilename, region string)
}

f := ini.Empty()
s, err := f.NewSection("profile " + profilename)
s, err := f.NewSection(profilename)
if err != nil {
return fmt.Errorf("Failed to create ini section: %w", err)
}
Expand Down
25 changes: 25 additions & 0 deletions cli/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cli

import (
"github.com/alecthomas/kingpin/v2"

"github.com/99designs/keyring"
)

func ExampleExportCommand() {
app := kingpin.New("aws-vault", "")
awsVault := ConfigureGlobals(app)
awsVault.keyringImpl = keyring.NewArrayKeyring([]keyring.Item{
{Key: "llamas", Data: []byte(`{"AccessKeyID":"ABC","SecretAccessKey":"XYZ"}`)},
})
ConfigureExportCommand(app, awsVault)
kingpin.MustParse(app.Parse([]string{
"export", "--format=ini", "--no-session", "llamas",
}))

// Output:
// [llamas]
// aws_access_key_id=ABC
// aws_secret_access_key=XYZ
// region=us-east-1
}

0 comments on commit a4f5e3d

Please sign in to comment.