@@ -3,7 +3,6 @@ package create
33import (
44 "context"
55 "fmt"
6- "strings"
76
87 "github.com/spf13/cobra"
98 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
@@ -12,7 +11,6 @@ import (
1211 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1312 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1413 "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
15- "github.com/stackitcloud/stackit-cli/internal/pkg/tables"
1614 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
1715 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1816 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
@@ -147,40 +145,16 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
147145}
148146
149147func outputResult (p * print.Printer , outputFormat string , routingTable * iaas.RoutingTable ) error {
148+ if routingTable == nil {
149+ return fmt .Errorf ("routing-table is nil" )
150+ }
151+
152+ if routingTable .Id == nil {
153+ return fmt .Errorf ("create routing-table id is empty" )
154+ }
155+
150156 return p .OutputResult (outputFormat , routingTable , func () error {
151- if routingTable == nil {
152- return fmt .Errorf ("create routing-table response is empty" )
153- }
154-
155- if routingTable .Id == nil {
156- return fmt .Errorf ("create routing-table id is empty" )
157- }
158-
159- var labels []string
160- if routingTable .Labels != nil && len (* routingTable .Labels ) > 0 {
161- for key , value := range * routingTable .Labels {
162- labels = append (labels , fmt .Sprintf ("%s: %s" , key , value ))
163- }
164- }
165-
166- table := tables .NewTable ()
167- table .SetHeader ("ID" , "NAME" , "DESCRIPTION" , "DEFAULT" , "LABELS" , "SYSTEM ROUTES" , "DYNAMIC ROUTES" , "CREATED AT" , "UPDATED AT" )
168- table .AddRow (
169- utils .PtrString (routingTable .Id ),
170- utils .PtrString (routingTable .Name ),
171- utils .PtrString (routingTable .Description ),
172- utils .PtrString (routingTable .Default ),
173- strings .Join (labels , "\n " ),
174- utils .PtrString (routingTable .SystemRoutes ),
175- utils .PtrString (routingTable .DynamicRoutes ),
176- utils .ConvertTimePToDateTimeString (routingTable .CreatedAt ),
177- utils .ConvertTimePToDateTimeString (routingTable .UpdatedAt ),
178- )
179-
180- err := table .Display (p )
181- if err != nil {
182- return fmt .Errorf ("render table: %w" , err )
183- }
157+ p .Outputf ("Created Routing-Table with ID %q\n " , utils .PtrString (routingTable .Id ))
184158 return nil
185159 })
186160}
0 commit comments