/
default.go
59 lines (53 loc) · 1.12 KB
/
default.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
package scaffold
import (
"os"
"path/filepath"
"github.com/hashicorp/hcl"
"github.com/pluralsh/plural-cli/pkg/executor"
"github.com/pluralsh/plural-cli/pkg/utils/pathing"
"github.com/pluralsh/plural-cli/pkg/wkspace"
)
func Read(path string) (*Build, error) {
fullpath := pathing.SanitizeFilepath(filepath.Join(path, "build.hcl"))
contents, err := os.ReadFile(fullpath)
build := Build{}
if err != nil {
return &build, err
}
err = hcl.Decode(&build, string(contents))
if err != nil {
return &build, err
}
return &build, nil
}
func Default(w *wkspace.Workspace, name string) (b *Build) {
return &Build{
Metadata: &Metadata{Name: name},
Scaffolds: []*Scaffold{
{
Name: "terraform",
Path: "terraform",
Type: TF,
},
{
Name: "crds",
Type: CRD,
Path: "crds",
},
{
Name: "helm",
Type: HELM,
Path: pathing.SanitizeFilepath(filepath.Join("helm", name)),
Preflight: []*executor.Step{
{
Name: "update-deps",
Command: "plural",
Args: []string{"wkspace", "helm-deps"},
Target: "Chart.yaml",
Sha: "",
},
},
},
},
}
}