aztfmod / rovergo

The next version of Rover, the command line tool for Azure CAF Landingzones. Developed in Go
MIT License
10 stars 7 forks source link

Complete restructure - mother of all PRs #79

Closed benc-uk closed 3 years ago

benc-uk commented 3 years ago

Complete restructure and refactor. this is a monster PR

sebastus commented 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.