Skip to content

Commit a039ec5

Browse files
fix: copilot review
1 parent 1100e86 commit a039ec5

5 files changed

Lines changed: 36 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
Versioning follows [SemVer](https://semver.org/). Sections: **Added**, **Changed**, **Deprecated**, **Fixed**, **Removed**, **Known Limitations**, **Dependencies**. Only user-visible changes listed. Older entries may use non-standard section names.
4+
5+
## [v6.10.2] – June 2026
6+
7+
### Added
8+
- **Regional API list from all locations**: List commands for regional APIs (DNS, Kafka, VPN, DBaaS, Monitoring, Logging, CDN, CertManager) now query all locations by default and display a `Location` column. Use `--location` to filter to a specific location. `-o json` merges items from all locations; `-o api-json` returns an array of per-location responses.
9+
- **Multi-location tab completion**: Tab completion for regional resource IDs (e.g. `--cluster-id`, `--gateway-id`) now shows resources from all locations with location hints, when `--location` is not set.
10+
311
## [v6.10.1] – May 2026
412

513
### Added

internal/client/regional.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ func NewRegionalConfig(url string) *shared.Configuration {
2424

2525
// Apply log level (shared.SdkLogLevel is package-level, already set by main client init)
2626

27-
// Apply query params
27+
// Apply query params (mirrors builder.go logic, including deprecated --max-results)
28+
limit := viper.GetString(constants.FlagLimit)
29+
if argsContainAny([]string{"--" + constants.DeprecatedFlagMaxResults, "-M"}) {
30+
limit = viper.GetString(constants.DeprecatedFlagMaxResults)
31+
}
32+
2833
queryParams := map[string]string{
29-
"limit": viper.GetString(constants.FlagLimit),
34+
"limit": limit,
3035
"offset": viper.GetString(constants.FlagOffset),
3136
"depth": viper.GetString(constants.FlagDepth),
3237
"order-by": viper.GetString(constants.FlagOrderBy),

internal/core/flag-option.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,16 @@ func WithCompletionComplex(
8484
}
8585

8686
var allResults []string
87+
mergedDirective := cobra.ShellCompDirectiveNoFileComp
8788
for _, loc := range locations {
8889
normalizedLoc := strings.ReplaceAll(loc, "/", "-")
8990
viper.Set(constants.ArgServerUrl, fmt.Sprintf(baseURL, normalizedLoc))
9091

91-
results, _ := completionFunc(passedCmd, args, toComplete)
92+
results, directive := completionFunc(passedCmd, args, toComplete)
93+
if directive == cobra.ShellCompDirectiveError {
94+
continue // skip failed locations
95+
}
96+
mergedDirective &= directive
9297
for _, r := range results {
9398
if strings.Contains(r, "\t") {
9499
allResults = append(allResults, r+" ("+loc+")")
@@ -97,7 +102,7 @@ func WithCompletionComplex(
97102
}
98103
}
99104
}
100-
return allResults, cobra.ShellCompDirectiveNoFileComp
105+
return allResults, mergedDirective
101106
},
102107
)
103108
}

internal/core/regional_list.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"encoding/json"
55
"fmt"
6+
"sort"
67
"strings"
78
"sync"
89

@@ -101,19 +102,27 @@ func (c *CommandConfig) ListAllLocations(
101102
if len(errCounts) == 1 {
102103
return fmt.Errorf("failed to list from all locations: %w", lastErr)
103104
}
104-
// Multiple distinct errors — join them
105+
// Multiple distinct errors — join them (sorted for stable output)
105106
var parts []string
106107
for msg, locs := range errCounts {
108+
sort.Strings(locs)
107109
parts = append(parts, fmt.Sprintf("%s: %s", strings.Join(locs, ", "), msg))
108110
}
111+
sort.Strings(parts)
109112
return fmt.Errorf("failed to list from all locations:\n %s", strings.Join(parts, "\n "))
110113
}
111114

112-
// Partial failure — warn only for failed locations
115+
// Partial failure — warn only for failed locations (sorted for stable output)
113116
if len(errCounts) > 0 {
114117
stderr := c.Command.Command.ErrOrStderr()
118+
var warns []string
115119
for msg, locs := range errCounts {
116-
fmt.Fprintf(stderr, "WARN: failed to list from %s: %s\n", strings.Join(locs, ", "), msg)
120+
sort.Strings(locs)
121+
warns = append(warns, fmt.Sprintf("WARN: failed to list from %s: %s", strings.Join(locs, ", "), msg))
122+
}
123+
sort.Strings(warns)
124+
for _, w := range warns {
125+
fmt.Fprintln(stderr, w)
117126
}
118127
}
119128

@@ -141,13 +150,14 @@ func (c *CommandConfig) regionalLegacyJSON(results []locResult) error {
141150
if r.err != nil {
142151
continue
143152
}
144-
// Marshal/unmarshal to get a generic map, then extract items
145153
b, err := json.Marshal(r.data)
146154
if err != nil {
155+
fmt.Fprintf(c.Command.Command.ErrOrStderr(), "WARN: failed to marshal response from %s: %v\n", r.location, err)
147156
continue
148157
}
149158
var m map[string]any
150159
if err := json.Unmarshal(b, &m); err != nil {
160+
fmt.Fprintf(c.Command.Command.ErrOrStderr(), "WARN: failed to parse response from %s: %v\n", r.location, err)
151161
continue
152162
}
153163
if items, ok := m["items"].([]any); ok {

internal/printer/table/table.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ func (t *Table) AppendRow(row map[string]any) {
169169
t.rows = append(t.rows, row)
170170
}
171171

172-
// SetRaw replaces the raw source data used for JSON output modes.
173-
// Used by ListAllLocations to set the merged array of per-location responses.
174-
func (t *Table) SetRaw(data any) {
175-
t.raw = data
176-
}
177-
178172
// SetCell sets a value for a specific column in a specific row.
179173
// Useful for post-extraction adjustments.
180174
func (t *Table) SetCell(row int, col string, value any) {

0 commit comments

Comments
 (0)