-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMagefile.go
62 lines (52 loc) · 1.6 KB
/
Magefile.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
//+build mage
package main
import (
"os"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
// BuildDockerImage builds all artifacts in a docker multi stage build
// and results in a Docker Image containing the artifacts
func BuildDockerImage() error {
return sh.RunV("docker", "build", "-f", "build/Dockerfile", "-t", "nicktriller/helm-cabin:latest", ".")
}
// BuildBackend locally runs the backend with `go run`.
// This target is supposed to be run in development only and assumes tiller is
// reachable at 127.0.0.1:44134
func RunServer() error {
helmVersion := "3"
if value, ok := os.LookupEnv("CABIN_HELM_VERSION"); ok {
helmVersion = value
}
return sh.RunV("go", "run", "cmd/helmcabin/main.go", "--tillerAddress", "127.0.0.1:44134",
"--listenAddress", "localhost:8080", "--helmVersion", helmVersion)
}
// BuildServerAll locally builds the artifacts for all supported platforms
func BuildServerAll() error {
if err := BuildServerWindows(); err != nil {
return err
}
return BuildServerLinux()
}
// BuildWindows locally builds the artifacts for windows
func BuildServerWindows() error {
return buildLocal("windows", "amd64")
}
// BuildWindows locally builds the artifacts for linux
func BuildServerLinux() error {
return buildLocal("linux", "amd64")
}
// Lint lints the go code
func Lint() error {
return sh.RunV("golint", "./...")
}
func buildLocal(goos string, goarch string) error {
mg.Deps(Lint)
_ = os.Setenv("GOOS", goos)
_ = os.Setenv("GOARCH", goarch)
out := "bin/helmcabin"
if goos == "windows" {
out += ".exe"
}
return sh.RunV("go", "build", "-o", out, "./cmd/helmcabin")
}