Skip to content

Commit

Permalink
main: move env into the executable
Browse files Browse the repository at this point in the history
bubble up into executable (from the root command)
the deployer.Environment management, to make room
to discover the control plane info.

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Jul 31, 2024
1 parent 0b65fcb commit da17968
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions pkg/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ func ShowHelp(cmd *cobra.Command, args []string) error {
type NewCommandFunc func(ev *deployer.Environment, ko *options.Options) *cobra.Command

// NewRootCommand returns entrypoint command to interact with all other commands
func NewRootCommand(extraCmds ...NewCommandFunc) *cobra.Command {
env := deployer.Environment{
Ctx: context.Background(),
Log: stdr.New(log.New(os.Stderr, "", log.LstdFlags)),
}
func NewRootCommand(env *deployer.Environment, extraCmds ...NewCommandFunc) *cobra.Command {
internalOpts := internalOptions{}
commonOpts := options.Options{}

Expand All @@ -66,7 +62,7 @@ func NewRootCommand(extraCmds ...NewCommandFunc) *cobra.Command {
Short: "deployer helps setting up all the topology-aware-scheduling components on a kubernetes cluster",

PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return PostSetupOptions(&env, &commonOpts, &internalOpts)
return PostSetupOptions(env, &commonOpts, &internalOpts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return ShowHelp(cmd, args)
Expand All @@ -78,16 +74,16 @@ func NewRootCommand(extraCmds ...NewCommandFunc) *cobra.Command {
InitFlags(root.PersistentFlags(), &commonOpts, &internalOpts)

root.AddCommand(
NewRenderCommand(&env, &commonOpts),
NewValidateCommand(&env, &commonOpts),
NewDeployCommand(&env, &commonOpts),
NewRemoveCommand(&env, &commonOpts),
NewSetupCommand(&env, &commonOpts),
NewDetectCommand(&env, &commonOpts),
NewImagesCommand(&env, &commonOpts),
NewRenderCommand(env, &commonOpts),
NewValidateCommand(env, &commonOpts),
NewDeployCommand(env, &commonOpts),
NewRemoveCommand(env, &commonOpts),
NewSetupCommand(env, &commonOpts),
NewDetectCommand(env, &commonOpts),
NewImagesCommand(env, &commonOpts),
)
for _, extraCmd := range extraCmds {
root.AddCommand(extraCmd(&env, &commonOpts))
root.AddCommand(extraCmd(env, &commonOpts))
}

return root
Expand Down

0 comments on commit da17968

Please sign in to comment.