Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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