@@ -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