Skip to content

Commit

Permalink
fix: missing projectName context in prompt:execute (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcheung authored Aug 30, 2021
1 parent 1c4180e commit 0672248
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Init(outDir string, localModulePath string) *projectconfig.ZeroProjectConfi
// Prompting for push-up stream, then conditionally prompting for github
prompts["GithubRootOrg"].RunPrompt(initParams, emptyEnvVarTranslationMap)

projectData := promptAllModules(moduleConfigs)
projectData := promptAllModules(moduleConfigs, &projectConfig)

// Map parameter values back to specific modules
for moduleName, module := range moduleConfigs {
Expand Down
12 changes: 10 additions & 2 deletions internal/init/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

tm "github.com/buger/goterm"
"github.com/commitdev/zero/internal/config/moduleconfig"
"github.com/commitdev/zero/internal/config/projectconfig"
"github.com/commitdev/zero/internal/constants"
"github.com/commitdev/zero/internal/util"
"github.com/commitdev/zero/pkg/util/exit"
Expand Down Expand Up @@ -276,8 +277,8 @@ func PromptModuleParams(moduleConfig moduleconfig.ModuleConfig, parameters map[s
// promptAllModules takes a map of all the modules and prompts the user for values for all the parameters
// Important: This is done here because in this step we share the parameter across modules,
// meaning if module A and B both asks for region, it will reuse the response for both (and is deduped during runtime)
func promptAllModules(modules map[string]moduleconfig.ModuleConfig) map[string]string {
parameterValues := map[string]string{}
func promptAllModules(modules map[string]moduleconfig.ModuleConfig, projectConfig *projectconfig.ZeroProjectConfig) map[string]string {
parameterValues := availableProjectContext(projectConfig)
for _, config := range modules {
var err error

Expand All @@ -289,6 +290,13 @@ func promptAllModules(modules map[string]moduleconfig.ModuleConfig) map[string]s
return parameterValues
}

// availableProjectContext declares a list of variables usable in modules parameter prompt's execute step
func availableProjectContext(projectConfig *projectconfig.ZeroProjectConfig) map[string]string {
return map[string]string{
"projectName": projectConfig.Name,
}
}

func paramConditionsMapper(conditions []moduleconfig.Condition) CustomConditionSignature {
if len(conditions) == 0 {
return NoCondition
Expand Down

0 comments on commit 0672248

Please sign in to comment.