forked from Q42Philips/gitops-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (40 loc) · 1002 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
43
44
45
46
47
package main
import (
"context"
"log"
"os"
"github.com/Q42Philips/gitops-sync/cmd/sync"
"github.com/Q42Philips/gitops-sync/pkg/config"
. "github.com/Q42Philips/gitops-sync/pkg/config"
"github.com/Q42Philips/gitops-sync/pkg/gitlogic"
)
// version information added by Goreleaser
var (
version = "development"
commit = "development"
)
func init() {
log.SetFlags(0)
log.Printf("Running gitops-sync %s (%s)", version, commit)
}
func main() {
Global := config.Config{}
Global.Init()
Global.ParseAndValidate()
result, err := sync.Main(Global)
if err != nil {
os.Exit(1)
} else {
os.Stdout.Write([]byte(result.Commit.String() + "\n"))
}
if Global.WaitForTags.Glob != nil {
log.Printf("Waiting for tags (%q) to include synced commit", Global.WaitForTags.String())
err = gitlogic.WaitForTags(context.Background(), Global, result.Commit.Hash, result.Repository)
if err != nil {
log.Printf("Error waiting for tags: %s", err)
os.Exit(1)
} else {
os.Exit(0)
}
}
}