Skip to content

Commit 96a4e46

Browse files
authored
chore(instance): add APIIDs filter to PCU requests to reduce cassette size (#5486)
1 parent d215164 commit 96a4e46

12 files changed

+1786
-609
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/moby/buildkit v0.29.0
2626
github.com/moby/go-archive v0.2.0
2727
github.com/opencontainers/go-digest v1.0.0
28-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260410085437-583409c79721
28+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260416143224-746704f18a9f
2929
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3030
github.com/spf13/cobra v1.10.2
3131
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
476476
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
477477
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
478478
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
479-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260410085437-583409c79721 h1:cysx/Agxy/gRF3WLMPh/0hcSj8QBRDEyQI/nG3a2j8Y=
480-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260410085437-583409c79721/go.mod h1:jG9ApeokegM68b/6vebk8fAhBJbqZKUoor/+f19+bH0=
479+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260416143224-746704f18a9f h1:uRw/kv3yB8Ivlca4RsZMo4pCXQm01g/X+K0pCd0Em+I=
480+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260416143224-746704f18a9f/go.mod h1:jG9ApeokegM68b/6vebk8fAhBJbqZKUoor/+f19+bH0=
481481
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
482482
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
483483
github.com/secure-systems-lab/go-securesystemslib v0.10.0 h1:l+H5ErcW0PAehBNrBxoGv1jjNpGYdZ9RcheFkB2WI14=

internal/namespaces/instance/v1/custom_server_type.go

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,13 @@ func serverTypeListBuilder(c *core.Command) *core.Command {
102102
ProductTypes: []product_catalog.ListPublicCatalogProductsRequestProductType{
103103
instanceProductType,
104104
},
105-
Zone: &request.Zone,
106-
Status: nil,
105+
Zone: &request.Zone,
106+
Status: []product_catalog.ListPublicCatalogProductsRequestStatus{
107+
product_catalog.ListPublicCatalogProductsRequestStatusPublicBeta,
108+
product_catalog.ListPublicCatalogProductsRequestStatusPreview,
109+
product_catalog.ListPublicCatalogProductsRequestStatusGeneralAvailability,
110+
product_catalog.ListPublicCatalogProductsRequestStatusEndOfNewFeatures,
111+
},
107112
},
108113
scw.WithAllPages(),
109114
scw.WithContext(ctx),
@@ -132,27 +137,6 @@ func serverTypeListBuilder(c *core.Command) *core.Command {
132137
serverTypes := []*customServerType(nil)
133138

134139
for _, pcuServerType := range listServersTypesResponse.Products {
135-
switch pcuServerType.Status {
136-
case product_catalog.PublicCatalogProductStatusUnknownStatus:
137-
continue
138-
case product_catalog.PublicCatalogProductStatusPublicBeta:
139-
case product_catalog.PublicCatalogProductStatusPreview:
140-
case product_catalog.PublicCatalogProductStatusGeneralAvailability:
141-
case product_catalog.PublicCatalogProductStatusEndOfNewFeatures:
142-
case product_catalog.PublicCatalogProductStatusEndOfGrowth:
143-
continue
144-
case product_catalog.PublicCatalogProductStatusEndOfDeployment:
145-
continue
146-
case product_catalog.PublicCatalogProductStatusEndOfSupport:
147-
continue
148-
case product_catalog.PublicCatalogProductStatusEndOfSale:
149-
continue
150-
case product_catalog.PublicCatalogProductStatusEndOfLife:
151-
continue
152-
case product_catalog.PublicCatalogProductStatusRetired:
153-
continue
154-
}
155-
156140
name := pcuServerType.Properties.Instance.OfferID
157141
serverType := &customServerType{
158142
Name: name,

internal/namespaces/instance/v1/helpers_types.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ func getEndOfServiceDate(
121121
ProductTypes: []product_catalog.ListPublicCatalogProductsRequestProductType{
122122
product_catalog.ListPublicCatalogProductsRequestProductTypeInstance,
123123
},
124+
Zone: &zone,
125+
APIIDs: []string{commercialType},
124126
},
125127
scw.WithAllPages(),
126128
scw.WithContext(ctx),
@@ -129,12 +131,13 @@ func getEndOfServiceDate(
129131
return "", fmt.Errorf("could not list product catalog entries: %w", err)
130132
}
131133

132-
for _, product := range products.Products {
133-
if product.Properties != nil && product.Properties.Instance != nil &&
134-
product.Properties.Instance.OfferID == commercialType {
135-
return product.EndOfLifeAt.Format(time.DateOnly), nil
136-
}
134+
if products.TotalCount != 1 {
135+
return "", fmt.Errorf(
136+
"expected exactly 1 PCU entry for %q, got %d",
137+
commercialType,
138+
products.TotalCount,
139+
)
137140
}
138141

139-
return "", fmt.Errorf("could not find product catalog entry for %q in %s", commercialType, zone)
142+
return products.Products[0].EndOfLifeAt.Format(time.DateOnly), nil
140143
}

internal/namespaces/instance/v1/testdata/test-server-type-list-on-fr-par1.cassette.yaml

Lines changed: 43 additions & 38 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)