forked from 99designs/aws-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_test.go
More file actions
35 lines (28 loc) · 844 Bytes
/
add_test.go
File metadata and controls
35 lines (28 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cli
// nolint:depguard
import (
"log"
"os"
"github.com/alecthomas/kingpin/v2"
)
func ExampleAddCommand() {
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
}