forked from EngineerBetter/concourse-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
100 lines (86 loc) · 3.97 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"errors"
"fmt"
"os"
"strings"
"github.com/EngineerBetter/concourse-up/bosh"
"github.com/EngineerBetter/concourse-up/commands"
"github.com/EngineerBetter/concourse-up/director"
"github.com/EngineerBetter/concourse-up/fly"
"github.com/EngineerBetter/concourse-up/terraform"
"github.com/fatih/color"
"gopkg.in/urfave/cli.v1"
)
// ConcourseUpVersion is a compile-time variable set with -ldflags
var ConcourseUpVersion = "COMPILE_TIME_VARIABLE_main_concourseUpVersion"
var blue = color.New(color.FgCyan, color.Bold).SprintfFunc()
func main() {
app := cli.NewApp()
app.Name = "Concourse-Up"
app.Usage = "A CLI tool to deploy Concourse CI"
app.Version = ConcourseUpVersion
app.Commands = commands.Commands
app.Flags = commands.GlobalFlags
cli.AppHelpTemplate = fmt.Sprintf(`%s
See 'concourse-up help <command>' to read about a specific command.
Built by %s %s
`, cli.AppHelpTemplate, blue("EngineerBetter"), blue("http://engineerbetter.com"))
if err := checkCompileTimeArgs(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func checkCompileTimeArgs() error {
boshCompileTimeArgs := map[string]string{
"bosh.ConcourseReleaseSHA1": bosh.ConcourseReleaseSHA1,
"bosh.ConcourseReleaseURL": bosh.ConcourseReleaseURL,
"bosh.ConcourseReleaseVersion": bosh.ConcourseReleaseVersion,
"bosh.ConcourseStemcellSHA1": bosh.ConcourseStemcellSHA1,
"bosh.ConcourseStemcellURL": bosh.ConcourseStemcellURL,
"bosh.ConcourseStemcellVersion": bosh.ConcourseStemcellVersion,
"bosh.DirectorCPIReleaseSHA1": bosh.DirectorCPIReleaseSHA1,
"bosh.DirectorCPIReleaseURL": bosh.DirectorCPIReleaseURL,
"bosh.DirectorCPIReleaseVersion": bosh.DirectorCPIReleaseVersion,
"bosh.DirectorReleaseSHA1": bosh.DirectorReleaseSHA1,
"bosh.DirectorReleaseURL": bosh.DirectorReleaseURL,
"bosh.DirectorReleaseVersion": bosh.DirectorReleaseVersion,
"bosh.DirectorStemcellSHA1": bosh.DirectorStemcellSHA1,
"bosh.DirectorStemcellURL": bosh.DirectorStemcellURL,
"bosh.DirectorStemcellVersion": bosh.DirectorStemcellVersion,
"bosh.GardenReleaseSHA1": bosh.GardenReleaseSHA1,
"bosh.GardenReleaseURL": bosh.GardenReleaseURL,
"bosh.GardenReleaseVersion": bosh.GardenReleaseVersion,
"bosh.GrafanaReleaseSHA1": bosh.GrafanaReleaseSHA1,
"bosh.GrafanaReleaseURL": bosh.GrafanaReleaseURL,
"bosh.GrafanaReleaseVersion": bosh.GrafanaReleaseVersion,
"bosh.InfluxDBReleaseSHA1": bosh.InfluxDBReleaseSHA1,
"bosh.InfluxDBReleaseURL": bosh.InfluxDBReleaseURL,
"bosh.InfluxDBReleaseVersion": bosh.InfluxDBReleaseVersion,
"bosh.RiemannReleaseSHA1": bosh.RiemannReleaseSHA1,
"bosh.RiemannReleaseURL": bosh.RiemannReleaseURL,
"bosh.RiemannReleaseVersion": bosh.RiemannReleaseVersion,
"director.DarwinBinaryURL": director.DarwinBinaryURL,
"director.LinuxBinaryURL": director.LinuxBinaryURL,
"director.WindowsBinaryURL": director.WindowsBinaryURL,
"fly.DarwinBinaryURL": fly.DarwinBinaryURL,
"fly.LinuxBinaryURL": fly.LinuxBinaryURL,
"fly.WindowsBinaryURL": fly.WindowsBinaryURL,
"terraform.DarwinBinaryURL": terraform.DarwinBinaryURL,
"terraform.LinuxBinaryURL": terraform.LinuxBinaryURL,
"terraform.WindowsBinaryURL": terraform.WindowsBinaryURL,
}
if ConcourseUpVersion == "" || strings.HasPrefix(ConcourseUpVersion, "COMPILE_TIME_VARIABLE") {
return errors.New("Compile-time variable main.ConcourseUpVersion not set, please build with: `go build -ldflags \"-X main.ConcourseUpVersion=0.0.0\"`")
}
for key, value := range boshCompileTimeArgs {
if value == "" || strings.HasPrefix(value, "COMPILE_TIME_VARIABLE") {
return fmt.Errorf("Compile-time variable %s not set, please build with: `go build -ldflags \"-X github.com/EngineerBetter/concourse-up/%s=SOME_VALUE\"`", key, key)
}
}
return nil
}