Skip to content

Commit a4f5e3d

Browse files
committed
Fix ini output to match credentials file
1 parent cec0d62 commit a4f5e3d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

cli/export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func printINI(credsProvider aws.CredentialsProvider, profilename, region string)
165165
}
166166

167167
f := ini.Empty()
168-
s, err := f.NewSection("profile " + profilename)
168+
s, err := f.NewSection(profilename)
169169
if err != nil {
170170
return fmt.Errorf("Failed to create ini section: %w", err)
171171
}

cli/export_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cli
2+
3+
import (
4+
"github.com/alecthomas/kingpin/v2"
5+
6+
"github.com/99designs/keyring"
7+
)
8+
9+
func ExampleExportCommand() {
10+
app := kingpin.New("aws-vault", "")
11+
awsVault := ConfigureGlobals(app)
12+
awsVault.keyringImpl = keyring.NewArrayKeyring([]keyring.Item{
13+
{Key: "llamas", Data: []byte(`{"AccessKeyID":"ABC","SecretAccessKey":"XYZ"}`)},
14+
})
15+
ConfigureExportCommand(app, awsVault)
16+
kingpin.MustParse(app.Parse([]string{
17+
"export", "--format=ini", "--no-session", "llamas",
18+
}))
19+
20+
// Output:
21+
// [llamas]
22+
// aws_access_key_id=ABC
23+
// aws_secret_access_key=XYZ
24+
// region=us-east-1
25+
}

0 commit comments

Comments
 (0)