Skip to content

Commit 040beb3

Browse files
fix: site:list --upstream takes uuids, not names
The upstream command help text is wrong too. pantheon-systems/terminus#2754
1 parent 04edcbc commit 040beb3

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

internal/commands/site.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func init() {
7878
siteListCmd.Flags().StringVar(&siteOrgFlag, "org", "", "Filter by organization")
7979
siteListCmd.Flags().StringVar(&siteOwnerFlag, "owner", "", "Owner filter; \"me\" or user UUID")
8080
siteListCmd.Flags().BoolVar(&siteTeamFlag, "team", false, "Filter sites of which the user is a team member")
81-
siteListCmd.Flags().StringVar(&siteUpstreamFlag, "upstream", "", "Upstream name to filter")
81+
siteListCmd.Flags().StringVar(&siteUpstreamFlag, "upstream", "", "Upstream UUID to filter")
8282

8383
siteCreateCmd.Flags().StringVar(&siteOrgFlag, "org", "", "Organization ID")
8484
siteCreateCmd.Flags().StringVar(&siteRegionFlag, "region", "", "Preferred region")
@@ -282,7 +282,7 @@ func filterSites(sites []*models.Site, currentUserID string) []*models.Site {
282282
}
283283
}
284284

285-
// Apply --upstream filter
285+
// Apply --upstream filter (UUID only)
286286
if siteUpstreamFlag != "" {
287287
upstreamMatch := false
288288

@@ -299,11 +299,6 @@ func filterSites(sites []*models.Site, currentUserID string) []*models.Site {
299299
}
300300
}
301301

302-
// Also check against the upstream label
303-
if site.UpstreamLabel == siteUpstreamFlag {
304-
upstreamMatch = true
305-
}
306-
307302
if !upstreamMatch {
308303
continue
309304
}

pkg/api/models/models.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ func (s *Site) UnmarshalJSON(data []byte) error {
161161

162162
// Format upstream as "id: url" to match PHP terminus
163163
var upstreamID, upstreamURL string
164-
if id, ok := upstreamMap["id"].(string); ok {
164+
// The API returns product_id, not id
165+
if id, ok := upstreamMap["product_id"].(string); ok {
165166
upstreamID = id
166167
}
167168
if url, ok := upstreamMap["url"].(string); ok {

pkg/api/testdata/fixtures/site_list.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
"organization": "",
99
"service_level": "free",
1010
"plan_name": "Sandbox",
11-
"upstream": {
12-
"branch": "main",
13-
"product_id": "bde48795-b16d-443f-af01-8b1790caa1af",
14-
"url": "https://github.com/pantheon-upstreams/drupal-composer-managed.git"
15-
},
11+
"upstream": "bde48795-b16d-443f-af01-8b1790caa1af: https://github.com/pantheon-upstreams/drupal-composer-managed.git",
1612
"php_version": "72",
1713
"holder_type": "user",
1814
"holder_id": "9cbc8751-968b-4d4f-9d23-909aea390817",

0 commit comments

Comments
 (0)