Skip to content

Commit bbaf538

Browse files
authored
Merge pull request #163 from commitdev/integrate-project-config-struct-changes
Integrate previous changes with new project config struct. This shoul…
2 parents bec2700 + 5456569 commit bbaf538

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
99
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
1010
github.com/coreos/go-semver v0.2.0
11+
github.com/google/go-cmp v0.3.0
1112
github.com/google/uuid v1.1.1
1213
github.com/gorilla/handlers v1.4.2
1314
github.com/gorilla/mux v1.7.3

internal/context/init.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
project "github.com/commitdev/zero/pkg/credentials"
1919
"github.com/commitdev/zero/pkg/util/exit"
2020
"github.com/commitdev/zero/pkg/util/flog"
21+
"github.com/k0kubun/pp"
2122
"github.com/manifoldco/promptui"
2223
)
2324

@@ -41,9 +42,6 @@ func Init(outDir string) *projectconfig.ZeroProjectConfig {
4142

4243
moduleSources := chooseStack(getRegistry())
4344
moduleConfigs := loadAllModules(moduleSources)
44-
for _ = range moduleConfigs {
45-
// TODO: initialize module structs inside project
46-
}
4745

4846
prompts := getProjectPrompts(projectConfig.Name, moduleConfigs)
4947

@@ -64,20 +62,29 @@ func Init(outDir string) *projectconfig.ZeroProjectConfig {
6462
}
6563

6664
projectParameters := promptAllModules(moduleConfigs)
67-
for k, v := range projectParameters {
68-
projectConfig.Parameters[k] = v
69-
// TODO: Add parameters to module structs inside project
70-
}
7165

72-
for moduleName, _ := range moduleConfigs {
73-
// @TODO : Uncomment when this struct is implemented
66+
// Map parameter values back to specific modules
67+
for moduleName, module := range moduleConfigs {
7468
repoName := prompts[moduleName].GetParam(initParams)
7569
repoURL := fmt.Sprintf("%s/%s", initParams["GithubRootOrg"], repoName)
76-
//projectConfig.Modules[moduleName].Files.Directory = prompts[moduleName].GetParam(initParams)
77-
//projectConfig.Modules[moduleName].Files.Repository = repoURL
78-
fmt.Println(repoURL)
70+
projectModuleParams := make(projectconfig.Parameters)
71+
72+
// Loop through all the prompted values and find the ones relevant to this module
73+
for parameterKey, parameterValue := range projectParameters {
74+
for _, moduleParameter := range module.Parameters {
75+
if moduleParameter.Field == parameterKey {
76+
projectModuleParams[parameterKey] = parameterValue
77+
}
78+
}
79+
80+
}
81+
82+
projectConfig.Modules[moduleName] = projectconfig.NewModule(projectModuleParams, repoName, repoURL)
7983
}
8084

85+
// TODO : Write the project config file. For now, print.
86+
pp.Println(projectConfig)
87+
8188
// TODO: load ~/.zero/config.yml (or credentials)
8289
// TODO: prompt global credentials
8390

0 commit comments

Comments
 (0)