Closed benc-uk closed 3 years ago
Can we further isolate config and execute? Something like this:
pkg/landingzone/cobra.go:
func RunFromCLI(cmd *cobra.Command, action Action) []Options {
...
return []Options{opt}
}
pkg/symphony/cobra.go
func RunFromConfig(cmd *cobra.Command, action landingzone.Action) []Options {
...
if levelName == "" {
return conf.runAll(action, dryRun) <-- returns array of Options
}
...
return conf.RunLevel(*level, action, dryRun) <-- returns array of Options
root.go
var options []Options
if configFile != "" {
options = symphony.RunFromConfig(cmd)
} else {
options = landingzone.RunFromCLI(cmd)
}
for _, optionSet := range options {
_ = action.Execute(optionSet)
}
console.Success("Rover has finished")
os.Exit(0)
Then, a test can do the initial bit to build the options array and assert on its contents without running execute. An integration test can go on to run Execute and check the actual resources.
Complete restructure and refactor. this is a monster PR
ci
,cd
,landingzone
andlaunchpad
commands are goneci
andci_tasks
directory is replaced withcustom_actions
rover linter
androver finder
--config-dir
or the--config-file
flags, which changes between adhoc or single level mode (without a symphony YAML) and multi-level mode (with a symphony YAML)Action
withTerraformAction
andCustomAction
being implemenatons, and each of the terraform actions are separate implementations e.g.PlanAction
andApplyAction
.Execute(o *Options)
which is how they are run.