-
Notifications
You must be signed in to change notification settings - Fork 52
/
apply.go
46 lines (35 loc) · 1.39 KB
/
apply.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
package projectconfig
import (
"fmt"
"os/exec"
"path"
"path/filepath"
"strings"
"github.com/commitdev/zero/internal/util"
"github.com/commitdev/zero/pkg/util/flog"
)
// Apply will bootstrap the runtime environment for the project
func Apply(dir string, projectContext *ZeroProjectConfig, applyEnvironments []string) {
flog.Infof(":tada: Bootstrapping project %s. Please use the zero.[hcl, yaml] file to modify the project as needed. %s.", projectContext.Name)
flog.Infof("Cloud provider: %s", "AWS") // will this come from the config?
flog.Infof("Runtime platform: %s", "Kubernetes")
flog.Infof("Infrastructure executor: %s", "Terraform")
// other details...
makeAll(dir, projectContext, applyEnvironments)
}
func makeAll(dir string, projectContext *ZeroProjectConfig, applyEnvironments []string) error {
environmentArg := fmt.Sprintf("ENVIRONMENT=%s", strings.Join(applyEnvironments, ","))
envars := []string{environmentArg}
for _, module := range projectContext.Modules {
// TODO what's the root dir for these modules?
// what's the real path to these modules? It's probably not the module name...
modulePath, err := filepath.Abs(path.Join(dir, projectContext.Name, module.Files.Directory))
if err != nil {
return err
}
// @TODO mock exec?
output := util.ExecuteCommandOutput(exec.Command("make", environmentArg), modulePath, envars)
fmt.Println(output)
}
return nil
}