-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (37 loc) · 936 Bytes
/
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
package main
import (
"context"
"flag"
"fmt"
"os"
)
var configPath string
var dryRun bool
var forceSync bool
func main() {
flag.StringVar(&configPath, "config", ".circleci-schedule.json", "path of scheduled trigger json")
flag.BoolVar(&dryRun, "dryrun", false, "enabled dry-run mode")
flag.BoolVar(&forceSync, "forcesync", false, "delete schedules that does not exist in config. judge by only name match.")
flag.Parse()
config, err := LoadConfig(configPath)
if err != nil {
fmt.Printf("failed to load config file: %v\n", err)
os.Exit(1)
}
client, err := NewClient()
if err != nil {
fmt.Printf("failed to create client: %v\n", err)
os.Exit(1)
}
if dryRun {
fmt.Println("Execute as dry-run mode")
}
if forceSync {
fmt.Println("Execute as force-sync mode")
}
_, err = Sync(context.Background(), client, config, dryRun, forceSync)
if err != nil {
fmt.Printf("failed sync %v\n", err)
os.Exit(1)
}
}