@@ -38,7 +38,6 @@ type Environment struct {
38
38
Endpoint string `yaml:"endpoint"`
39
39
Proxy string `yaml:"proxy"`
40
40
Token string `yaml:"token"`
41
- URL string `yaml:"url"`
42
41
}
43
42
44
43
type Config struct {
@@ -58,9 +57,10 @@ type FetchOptions struct {
58
57
SortBy string
59
58
MinimalColumns bool
60
59
Columns string
61
- Limit int
60
+ Rows int
62
61
Page int
63
62
PageSize int
63
+ NoPaging bool
64
64
}
65
65
66
66
// FetchService handles the execution of gRPC commands for all services
@@ -205,12 +205,16 @@ func FetchService(serviceName string, verb string, resourceName string, options
205
205
}
206
206
207
207
domainParts := strings .Split (urlParts [1 ], "." )
208
- if len (domainParts ) < 4 {
209
- return nil , fmt .Errorf ("invalid domain format in API endpoint: %s" , apiEndpoint )
210
- }
208
+ if len (domainParts ) > 0 {
209
+ port := extractPortFromParts (domainParts )
210
+ if strings .Contains (domainParts [len (domainParts )- 1 ], ":" ) {
211
+ parts := strings .Split (domainParts [len (domainParts )- 1 ], ":" )
212
+ domainParts [len (domainParts )- 1 ] = parts [0 ]
213
+ }
211
214
212
- domainParts [0 ] = format .ConvertServiceName (serviceName )
213
- hostPort = strings .Join (domainParts , "." ) + ":443"
215
+ domainParts [0 ] = format .ConvertServiceName (serviceName )
216
+ hostPort = strings .Join (domainParts , "." ) + port
217
+ }
214
218
} else {
215
219
trimmedEndpoint := strings .TrimPrefix (identityEndpoint , "grpc+ssl://" )
216
220
parts := strings .Split (trimmedEndpoint , "." )
@@ -349,11 +353,10 @@ func FetchService(serviceName string, verb string, resourceName string, options
349
353
}
350
354
}
351
355
352
- // Apply limit if specified
353
- if options .Limit > 0 && verb == "list" {
356
+ if options .Rows > 0 && verb == "list" {
354
357
if results , ok := respMap ["results" ].([]interface {}); ok {
355
- if len (results ) > options .Limit {
356
- respMap ["results" ] = results [:options .Limit ]
358
+ if len (results ) > options .Rows {
359
+ respMap ["results" ] = results [:options .Rows ]
357
360
}
358
361
}
359
362
}
@@ -397,6 +400,22 @@ func extractParameterName(errMsg string) string {
397
400
return ""
398
401
}
399
402
403
+ func extractPortFromParts (parts []string ) string {
404
+ if len (parts ) == 0 {
405
+ return ":443"
406
+ }
407
+
408
+ lastPart := parts [len (parts )- 1 ]
409
+ if strings .Contains (lastPart , ":" ) {
410
+ portParts := strings .Split (lastPart , ":" )
411
+ if len (portParts ) == 2 {
412
+ return ":" + portParts [1 ]
413
+ }
414
+ }
415
+
416
+ return ":443"
417
+ }
418
+
400
419
// promptForParameter prompts the user to enter a value for the given parameter
401
420
func promptForParameter (paramName string ) (string , error ) {
402
421
prompt := fmt .Sprintf ("Please enter value for '%s'" , paramName )
@@ -431,7 +450,7 @@ func loadConfig() (*Config, error) {
431
450
envConfig := & Environment {
432
451
Endpoint : mainV .GetString (fmt .Sprintf ("environments.%s.endpoint" , currentEnv )),
433
452
Proxy : mainV .GetString (fmt .Sprintf ("environments.%s.proxy" , currentEnv )),
434
- URL : mainV .GetString (fmt .Sprintf ("environments.%s.url " , currentEnv )),
453
+ Token : mainV .GetString (fmt .Sprintf ("environments.%s.token " , currentEnv )),
435
454
}
436
455
437
456
// Handle token based on environment type
@@ -510,12 +529,16 @@ func fetchJSONResponse(config *Config, serviceName string, verb string, resource
510
529
}
511
530
512
531
domainParts := strings .Split (urlParts [1 ], "." )
513
- if len (domainParts ) < 4 {
514
- return nil , fmt .Errorf ("invalid domain format in API endpoint: %s" , apiEndpoint )
515
- }
532
+ if len (domainParts ) > 0 {
533
+ port := extractPortFromParts (domainParts )
534
+ if strings .Contains (domainParts [len (domainParts )- 1 ], ":" ) {
535
+ parts := strings .Split (domainParts [len (domainParts )- 1 ], ":" )
536
+ domainParts [len (domainParts )- 1 ] = parts [0 ]
537
+ }
516
538
517
- domainParts [0 ] = format .ConvertServiceName (serviceName )
518
- hostPort = strings .Join (domainParts , "." ) + ":443"
539
+ domainParts [0 ] = format .ConvertServiceName (serviceName )
540
+ hostPort = strings .Join (domainParts , "." ) + port
541
+ }
519
542
}
520
543
} else {
521
544
trimmedEndpoint := strings .TrimPrefix (identityEndpoint , "grpc+ssl://" )
@@ -985,9 +1008,14 @@ func getMinimalFields(serviceName, resourceName string, refClient *grpcreflect.C
985
1008
986
1009
func printTable (data map [string ]interface {}, options * FetchOptions , serviceName , verbName , resourceName string , refClient * grpcreflect.Client ) string {
987
1010
if results , ok := data ["results" ].([]interface {}); ok {
988
- // Set default page size if not specified
989
- if options .PageSize == 0 {
990
- options .PageSize = 10
1011
+ // Set default page size if not specified and paging is enabled
1012
+ if ! options .NoPaging {
1013
+ if options .PageSize == 0 {
1014
+ options .PageSize = 15
1015
+ }
1016
+ } else {
1017
+ // Show all results when no-paging is true
1018
+ options .PageSize = len (results )
991
1019
}
992
1020
993
1021
// Initialize keyboard
0 commit comments