-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (42 loc) · 1.03 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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/opentelekomcloud-infra/terraform-setter-lint/lint"
)
const help = "Simple lint checking that all resource attribute setters have " +
"corresponding attributes in the resource schema.\n\n" +
"\u001B[1mUsage:\u001B[0m\n terraform-setter-lint \u001B[2m[path]\u001B[0m\n\n" +
"\u001B[1mArguments:\u001B[0m\n" +
" path - Path to root directory, current dir if not provided.\n"
func init() {
flag.Usage = func() {
_, _ = fmt.Fprint(flag.CommandLine.Output(), help)
flag.PrintDefaults()
}
}
func main() {
flag.Parse()
path := "."
if flag.NArg() > 0 {
path = flag.Arg(0)
}
path, err := filepath.Abs(path)
if err != nil {
// virtually impossible, but
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
if _, err := os.Stat(path); os.IsNotExist(err) {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
println("Validating resources at", path)
if err := lint.Validate(path); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
println("OK")
}