diff --git a/internal/cmd/load-balancer/describe/describe.go b/internal/cmd/load-balancer/describe/describe.go index bfcb1ef6c..e2fac07f4 100644 --- a/internal/cmd/load-balancer/describe/describe.go +++ b/internal/cmd/load-balancer/describe/describe.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" "fmt" - "strconv" - "strings" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -161,36 +159,14 @@ func renderListeners(listeners []loadbalancer.Listener) string { listener := listeners[i] table.AddRow(*listener.Name, *listener.Port, *listener.Protocol, *listener.TargetPool) } - return table.Render() } func renderTargetPools(targetPools []loadbalancer.TargetPool) string { table := tables.NewTable() - table.SetHeader("TARGET POOL NAME", "PORT", "TARGETS", "SESSION PERSISTENCE", "HEALTH CHECK INTERVAL (S)", "DOWN AFTER (CHECKS)", "UP AFTER (CHECKS)") + table.SetHeader("TARGET POOL NAME", "PORT", "TARGETS") for _, targetPool := range targetPools { - var targetsArray []string - for _, t := range *targetPool.Targets { - targetsArray = append(targetsArray, fmt.Sprintf("%s (%s)", *t.DisplayName, *t.Ip)) - } - targets := strings.Join(targetsArray, "\n") - - sessionPersistence := "None" - if targetPool.SessionPersistence != nil && targetPool.SessionPersistence.UseSourceIpAddress != nil && *targetPool.SessionPersistence.UseSourceIpAddress { - sessionPersistence = "Use Source IP" - } - - healthCheckInterval := "-" - healthCheckUnhealthyThreshold := "-" - healthCheckHealthyThreshold := "-" - if targetPool.ActiveHealthCheck != nil { - healthCheckInterval = *targetPool.ActiveHealthCheck.Interval - healthCheckUnhealthyThreshold = strconv.FormatInt(*targetPool.ActiveHealthCheck.UnhealthyThreshold, 10) - healthCheckHealthyThreshold = strconv.FormatInt(*targetPool.ActiveHealthCheck.HealthyThreshold, 10) - } - - table.AddRow(*targetPool.Name, *targetPool.TargetPort, targets, sessionPersistence, healthCheckInterval, healthCheckUnhealthyThreshold, healthCheckHealthyThreshold) + table.AddRow(*targetPool.Name, *targetPool.TargetPort, len(*targetPool.Targets)) } - return table.Render() } diff --git a/internal/cmd/load-balancer/list/list.go b/internal/cmd/load-balancer/list/list.go index 49ab44e4a..05da661cb 100644 --- a/internal/cmd/load-balancer/list/list.go +++ b/internal/cmd/load-balancer/list/list.go @@ -64,8 +64,8 @@ func NewCmd(p *print.Printer) *cobra.Command { if err != nil { return fmt.Errorf("get load balancers: %w", err) } - loadBalancers := *resp.LoadBalancers - if len(loadBalancers) == 0 { + + if resp.LoadBalancers == nil || (resp.LoadBalancers != nil && len(*resp.LoadBalancers) == 0) { projectLabel, err := projectname.GetProjectName(ctx, p, cmd) if err != nil { p.Debug(print.ErrorLevel, "get project name: %v", err) @@ -75,6 +75,7 @@ func NewCmd(p *print.Printer) *cobra.Command { return nil } + loadBalancers := *resp.LoadBalancers // Truncate output if model.Limit != nil && len(loadBalancers) > int(*model.Limit) { loadBalancers = loadBalancers[:*model.Limit]