-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 1.21 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
package main
import (
"context"
"log"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/route53"
)
var conf Config
var client route53.Client
var action string
func main() {
action = parseFlags()
initConfig()
loadConfig()
client = initClient()
// Execute action based on flags
// log.Println("action was: ", action)
switch action {
case "records list <zone-id>":
listARecords()
case "records activate <zone-id> <resource-name>":
activateRecord(&CLI.Records.Activate.ZoneId, &CLI.Records.Activate.ResourceName)
case "records deactivate <resource-name>":
deactivateRecord(&CLI.Records.Deactivate.ResourceName)
case "records update <resource-name>", "records update <resource-name> <ip>":
updateRecordIP(&CLI.Records.Update.ResourceName, &CLI.Records.Update.IP)
case "zones list":
listZones()
case "server run":
startConfigWatcher() //config changes are watched only in server mode
startServer()
}
}
func initClient() route53.Client {
// load client config
cfg, err := config.LoadDefaultConfig(context.Background())
if err != nil {
log.Fatalf("unable to load SDK config: %v", err)
}
// Using the Config value, create the Route53 client
return *route53.NewFromConfig(cfg)
}