forked from deweysasser/eks-kubeconfig-update
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
70 lines (58 loc) · 1.31 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"os"
"github.com/alecthomas/kong"
"github.com/clouddrove/kuconf/program/aws"
"github.com/clouddrove/kuconf/program/azure"
"github.com/clouddrove/kuconf/program/gcp"
"github.com/rs/zerolog/log"
)
// main function
func main() {
if len(os.Args) < 2 {
fmt.Println("Please provide (aws, gcp or azure) as the first argument.")
os.Exit(1)
}
platform := os.Args[1]
var optionsGCP gcp.Options
var optionsAWS aws.Options
var optionsAZURE azure.Options
var ctx *kong.Context
var err error
switch platform {
case "gcp":
ctx, err = optionsGCP.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := ctx.Run(&optionsGCP); err != nil {
log.Err(err).Msg("Program failed for GCP")
os.Exit(1)
}
case "aws":
ctx, err = optionsAWS.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := ctx.Run(&optionsAWS); err != nil {
log.Err(err).Msg("Program failed for AWS")
os.Exit(1)
}
case "azure":
ctx, err = optionsAZURE.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := ctx.Run(&optionsAZURE); err != nil {
log.Err(err).Msg("Program failed for AZURE")
os.Exit(1)
}
default:
fmt.Println("Invalid cloud provider. Please choose either 'aws', 'gcp' or 'azure")
os.Exit(1)
}
}