Skip to content

Commit

Permalink
Merge pull request #163 from commitdev/integrate-project-config-struc…
Browse files Browse the repository at this point in the history
…t-changes

Integrate previous changes with new project config struct. This shoul…
  • Loading branch information
bmonkman committed Jun 15, 2020
2 parents bec2700 + 5456569 commit bbaf538
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -8,6 +8,7 @@ require (
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
github.com/coreos/go-semver v0.2.0
github.com/google/go-cmp v0.3.0
github.com/google/uuid v1.1.1
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.3
Expand Down
31 changes: 19 additions & 12 deletions internal/context/init.go
Expand Up @@ -18,6 +18,7 @@ import (
project "github.com/commitdev/zero/pkg/credentials"
"github.com/commitdev/zero/pkg/util/exit"
"github.com/commitdev/zero/pkg/util/flog"
"github.com/k0kubun/pp"
"github.com/manifoldco/promptui"
)

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

moduleSources := chooseStack(getRegistry())
moduleConfigs := loadAllModules(moduleSources)
for _ = range moduleConfigs {
// TODO: initialize module structs inside project
}

prompts := getProjectPrompts(projectConfig.Name, moduleConfigs)

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

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

for moduleName, _ := range moduleConfigs {
// @TODO : Uncomment when this struct is implemented
// Map parameter values back to specific modules
for moduleName, module := range moduleConfigs {
repoName := prompts[moduleName].GetParam(initParams)
repoURL := fmt.Sprintf("%s/%s", initParams["GithubRootOrg"], repoName)
//projectConfig.Modules[moduleName].Files.Directory = prompts[moduleName].GetParam(initParams)
//projectConfig.Modules[moduleName].Files.Repository = repoURL
fmt.Println(repoURL)
projectModuleParams := make(projectconfig.Parameters)

// Loop through all the prompted values and find the ones relevant to this module
for parameterKey, parameterValue := range projectParameters {
for _, moduleParameter := range module.Parameters {
if moduleParameter.Field == parameterKey {
projectModuleParams[parameterKey] = parameterValue
}
}

}

projectConfig.Modules[moduleName] = projectconfig.NewModule(projectModuleParams, repoName, repoURL)
}

// TODO : Write the project config file. For now, print.
pp.Println(projectConfig)

// TODO: load ~/.zero/config.yml (or credentials)
// TODO: prompt global credentials

Expand Down

0 comments on commit bbaf538

Please sign in to comment.