-
Notifications
You must be signed in to change notification settings - Fork 52
/
init.go
43 lines (33 loc) · 1.14 KB
/
init.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
package projectconfig
import (
"fmt"
"io/ioutil"
"path"
"github.com/commitdev/zero/internal/constants"
"github.com/commitdev/zero/pkg/util/exit"
)
const exampleConfig = `name: %s
# Context is normally populated automatically but could be used to inject global params
context:
# module can be in any format the go-getter supports (path, github, url, etc.)
# supports https://github.com/hashicorp/go-getter#url-format
# Example:
# - source: "../development/modules/ci"
# - output: "github-actions"
modules:
- source: "github.com/commitdev/zero-aws-eks-stack"
- source: "github.com/commitdev/zero-deployable-backend"
- source: "github.com/commitdev/zero-deployable-react-frontend"
`
var RootDir = "./"
func SetRootDir(dir string) {
RootDir = dir
}
func Init(dir string, projectName string, projectContext *ZeroProjectConfig) {
// TODO: template the zero-project.yml with projectContext
content := []byte(fmt.Sprintf(exampleConfig, projectName))
err := ioutil.WriteFile(path.Join(dir, projectName, constants.ZeroProjectYml), content, 0644)
if err != nil {
exit.Fatal(fmt.Sprintf("Failed to create example %s", constants.ZeroProjectYml))
}
}