/
root.go
41 lines (34 loc) · 808 Bytes
/
root.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
package cmd
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/spf13/cobra"
"log"
"os"
)
var cfg aws.Config
var client *kms.Client
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kms",
Short: "kms commands",
Long: `kms commands.`,
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
var err error
cfg, err = config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Fatal(err)
}
client = kms.NewFromConfig(cfg)
}