Skip to content

Commit

Permalink
Reorganize PersistentRunE hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
schnie committed Dec 20, 2024
1 parent 6fa7960 commit ca69f47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 5 additions & 1 deletion cmd/airflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"github.com/astronomer/astro-cli/cmd/utils"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -130,7 +131,10 @@ func newDevRootCmd(platformCoreClient astroplatformcore.CoreClient, astroCoreCli
// so we set that configuration in this persistent pre-run hook.
// A few sub-commands don't require this, so they explicitly
// clobber it with a no-op function.
PersistentPreRunE: ConfigureContainerRuntime,
PersistentPreRunE: utils.ChainRunEs(
SetupLogging,
ConfigureContainerRuntime,
),
}
cmd.AddCommand(
newAirflowInitCmd(),
Expand Down
5 changes: 0 additions & 5 deletions cmd/airflow_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"path/filepath"

"github.com/astronomer/astro-cli/airflow/runtimes"
softwareCmd "github.com/astronomer/astro-cli/cmd/software"
"github.com/astronomer/astro-cli/cmd/utils"
"github.com/astronomer/astro-cli/config"
"github.com/spf13/cobra"
Expand All @@ -29,10 +28,6 @@ func ConfigureContainerRuntime(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}

if err := softwareCmd.SetUpLogs(os.Stdout, verboseLevel); err != nil {
return err
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewRootCmd() *cobra.Command {
Welcome to the Astro CLI, the modern command line interface for data orchestration. You can use it for Astro, Astronomer Software, or Local Development.`,
PersistentPreRunE: utils.ChainRunEs(
SetupLoggingPersistentPreRunE,
SetupLogging,
CreateRootPersistentPreRunE(astroCoreClient, platformCoreClient),
),
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/root_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/spf13/cobra"
)

// SetupLoggingPersistentPreRunE is a pre-run hook shared between software & cloud
// SetupLogging is a pre-run hook shared between software & cloud
// setting up log verbosity.
func SetupLoggingPersistentPreRunE(_ *cobra.Command, _ []string) error {
func SetupLogging(_ *cobra.Command, _ []string) error {
return softwareCmd.SetUpLogs(os.Stdout, verboseLevel)
}

Expand Down

0 comments on commit ca69f47

Please sign in to comment.