forked from luthermonson/go-proxmox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magefile.go
70 lines (59 loc) · 1.46 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
63
64
65
66
67
68
69
70
//go:build mage
// +build mage
package main
import (
"fmt"
"os"
"strings"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
//mage:import install
"github.com/luthermonson/go-proxmox/mage/install"
//mage:import test
"github.com/luthermonson/go-proxmox/mage/test"
)
var (
envConfig = map[string]struct{}{
"PROXMOX_URL": {},
"PROXMOX_USERNAME": {},
"PROXMOX_PASSWORD": {},
"PROXMOX_OTP": {},
"PROXMOX_TOKENID": {},
"PROXMOX_SECRET": {},
"PROXMOX_NODE_NAME": {},
"PROXMOX_NODE_STORAGE": {},
"PROXMOX_APPLIANCE_PREFIX": {},
"PROXMOX_ISO_URL": {},
}
)
var Aliases = map[string]interface{}{
"test": test.Unit,
"install": install.Dependencies,
}
// run everything for ci process (install deps, lint, coverage, build)
func Ci() error {
fmt.Println("Running Continuous Integration...")
mg.Deps(
install.Dependencies,
Lint,
test.Coverage,
test.Build)
return nil
}
// run the linter
func Lint() error {
mg.Deps(install.Golangcilint)
fmt.Println("Running Linter...")
return sh.RunV("golangci-lint", "run")
}
// validate env vars to run the testing suite
func Env() error {
for k := range envConfig {
if strings.Contains(strings.ToLower(k), "password") || strings.Contains(strings.ToLower(k), "secret") {
fmt.Printf("%s: %s\n", k, strings.Repeat("*", len(os.Getenv(k))))
} else {
fmt.Printf("%s: %s\n", k, os.Getenv(k))
}
}
return nil
}