Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cloud/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/astronomer/astro-cli/context"
"github.com/astronomer/astro-cli/pkg/ansi"
"github.com/astronomer/astro-cli/pkg/input"
"github.com/astronomer/astro-cli/pkg/logger"
"github.com/astronomer/astro-cli/pkg/printutil"
)

Expand Down Expand Up @@ -54,13 +55,17 @@ func GetCurrentWorkspace() (string, error) {
func List(client astrocore.CoreClient, out io.Writer) error {
c, err := config.GetCurrentContext()
if err != nil {
logger.Debugf("Failed to get current context: %v", err)
return err
}
logger.Debugf("Current context - Organization: %s, Workspace: %s", c.Organization, c.Workspace)

ws, err := GetWorkspaces(client)
if err != nil {
logger.Debugf("Failed to fetch workspaces: %v", err)
return err
}
logger.Debugf("Successfully retrieved %d workspace(s)", len(ws))

tab := newTableOut()
for i := range ws {
Expand All @@ -71,6 +76,7 @@ func List(client astrocore.CoreClient, out io.Writer) error {

if c.Workspace == ws[i].Id {
color = true
logger.Debugf("Workspace '%s' (ID: %s) is the current workspace", name, workspace)
} else {
color = false
}
Expand Down
14 changes: 12 additions & 2 deletions cmd/root_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ import (

// SetupLogging is a pre-run hook shared between software & cloud
// setting up log verbosity.
func SetupLogging(_ *cobra.Command, _ []string) error {
return softwareCmd.SetUpLogs(os.Stdout, verboseLevel)
func SetupLogging(cmd *cobra.Command, _ []string) error {
// This fixes an issue where the package variable may not be properly bound in some build environments
level := verboseLevel
if cmd != nil {
if flagValue, err := cmd.Flags().GetString("verbosity"); err == nil && flagValue != "" {
level = flagValue
} else if flagValue, err := cmd.Root().PersistentFlags().GetString("verbosity"); err == nil && flagValue != "" {
level = flagValue
}
}

return softwareCmd.SetUpLogs(os.Stdout, level)
}

// CreateRootPersistentPreRunE takes clients as arguments and returns a cobra
Expand Down
6 changes: 6 additions & 0 deletions software/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/astronomer/astro-cli/config"
"github.com/astronomer/astro-cli/houston"
"github.com/astronomer/astro-cli/pkg/input"
"github.com/astronomer/astro-cli/pkg/logger"
"github.com/astronomer/astro-cli/pkg/printutil"
)

Expand Down Expand Up @@ -64,13 +65,17 @@ func Create(label, desc string, client houston.ClientInterface, out io.Writer) e
func List(client houston.ClientInterface, out io.Writer) error {
ws, err := houston.Call(client.ListWorkspaces)(nil)
if err != nil {
logger.Debugf("Failed to fetch workspaces: %v", err)
return err
}
logger.Debugf("Successfully retrieved %d workspace(s)", len(ws))

c, err := config.GetCurrentContext()
if err != nil {
logger.Debugf("Failed to get current context: %v", err)
return err
}
logger.Debugf("Current context - Workspace: %s", c.Workspace)

tab := newTableOut()
for i := range ws {
Expand All @@ -82,6 +87,7 @@ func List(client houston.ClientInterface, out io.Writer) error {

if c.Workspace == w.ID {
color = true
logger.Debugf("Workspace '%s' (ID: %s) is the current workspace", name, workspace)
} else {
color = false
}
Expand Down