Skip to content

Commit

Permalink
refactor: render or skip stack based on stackConfigs is provided or not
Browse files Browse the repository at this point in the history
  • Loading branch information
howieyuen committed Jun 30, 2022
1 parent afdf541 commit 6021fd1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pkg/scaffold/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,17 @@ func RenderFSTemplate(srcFS afero.Fs, srcDir string, destFS afero.Fs, destDir st
for k, v := range tc.ProjectConfig {
configs[k] = v
}
// Walk each stack
for stackName, stackConfigs := range tc.StacksConfig {
// Use stack name as sub dir
dest = filepath.Join(destDir, stackName)
// Merge and override project config
for k, v := range stackConfigs {
configs[k] = v
}
// Walk stack dir with merged configs
err = walkFiles(srcFS, src, destFS, dest, configs)
if err != nil {
return err
}
// Skip if stackConfigs are not provided
stackConfigs, exits := tc.StacksConfig[fileInfo.Name()]
if !exits {
continue
}
// Merge and override project config
for k, v := range stackConfigs {
configs[k] = v
}
// Walk stack dir with merged configs
err = walkFiles(srcFS, src, destFS, dest, configs)
} else {
// Stack dir nested in 3rd level or even deeper, eg: meta_app/deployed_unit/stack_dir
err = RenderFSTemplate(srcFS, src, destFS, dest, tc)
Expand Down

0 comments on commit 6021fd1

Please sign in to comment.