-
Notifications
You must be signed in to change notification settings - Fork 20
/
environment.go
52 lines (43 loc) · 1.3 KB
/
environment.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var envCmd = &cobra.Command{
Use: "env",
Hidden: true,
Run: func(cmd *cobra.Command, _ []string) {
vars := map[string]string{
"EXOSCALE_API_KEY": gCurrentAccount.Key,
"EXOSCALE_API_SECRET": gCurrentAccount.Secret,
"EXOSCALE_API_ENDPOINT": gCurrentAccount.Endpoint,
"EXOSCALE_API_ENVIRONMENT": gCurrentAccount.Environment,
}
unset, _ := cmd.Flags().GetBool("unset")
for k, v := range vars {
if unset {
fmt.Printf("unset %s\n", k)
} else {
fmt.Printf("export %s=%q\n", k, v)
}
}
},
}
func init() {
RootCmd.AddCommand(&cobra.Command{
Use: "environment",
Short: "Environment variables usage",
Long: `The exo CLI tool allows users to override some account configuration settings
by specifying shell environment variables. Here is the list of environment
variables supported:
* EXOSCALE_API_KEY: the Exoscale client API key
* EXOSCALE_API_SECRET: the Exoscale client API secret
* EXOSCALE_API_ENDPOINT: the Exoscale (Compute) API endpoint to use
Note: to override the current profile API credentials, *both* EXOSCALE_API_KEY
and EXOSCALE_API_SECRET variables have to be set.
`,
},
)
envCmd.Flags().BoolP("unset", "u", false, "unset EXOSCALE_* environment variables")
RootCmd.AddCommand(envCmd)
}