From c31c81f85d69193e58175fbdcf06502acb329d9b Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Sat, 17 Oct 2026 01:02:33 +0200 Subject: [PATCH] fix(gcp/memorystore): list Redis SKUs from the Cloud Memorystore for Redis billing service The hardcoded billing service ID returned 404 from the live Cloud Billing API, so Memorystore pricing could never load. Use services/5AF5-2C11-D467 via a named const and assert the ID passed to ListSKUs. Closes #380 Co-Authored-By: Claude Opus 5.5 --- providers/gcp/services/memorystore/client.go | 5 +++- .../services/memorystore/service_id_test.go | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 providers/gcp/services/memorystore/service_id_test.go diff --git a/providers/gcp/services/memorystore/client.go b/providers/gcp/services/memorystore/client.go index cddd7c8..020bea2 100644 --- a/providers/gcp/services/memorystore/client.go +++ b/providers/gcp/services/memorystore/client.go @@ -544,6 +544,9 @@ func (c *Client) convertGCPRecommendation(ctx context.Context, gcpRec *recommend return rec } +// memorystoreRedisServiceID is the Cloud Billing service for Cloud Memorystore for Redis. +const memorystoreRedisServiceID = "services/5AF5-2C11-D467" + // listSKUs returns the service's SKU catalog, listing it once per client so // that pricing N recommendations costs one catalog read instead of N. func (c *Client) listSKUs(svc BillingService) (*cloudbilling.ListSkusResponse, error) { @@ -552,7 +555,7 @@ func (c *Client) listSKUs(svc BillingService) (*cloudbilling.ListSkusResponse, e if c.skuCache != nil { return c.skuCache, nil } - skus, err := svc.ListSKUs("services/D559-82DA-3A56") + skus, err := svc.ListSKUs(memorystoreRedisServiceID) if err != nil { return nil, err } diff --git a/providers/gcp/services/memorystore/service_id_test.go b/providers/gcp/services/memorystore/service_id_test.go new file mode 100644 index 0000000..59befc2 --- /dev/null +++ b/providers/gcp/services/memorystore/service_id_test.go @@ -0,0 +1,29 @@ +package memorystore + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/api/cloudbilling/v1" +) + +type serviceIDSpy struct{ got []string } + +func (s *serviceIDSpy) ListSKUs(serviceID string) (*cloudbilling.ListSkusResponse, error) { + s.got = append(s.got, serviceID) + return &cloudbilling.ListSkusResponse{}, nil +} + +// Regression for #380: the previous ID returned 404 from the live Billing API. +func TestListSKUs_UsesMemorystoreForRedisServiceID(t *testing.T) { + client, err := NewClient(context.Background(), "test-project", "us-central1") + require.NoError(t, err) + spy := &serviceIDSpy{} + + _, err = client.listSKUs(spy) + + require.NoError(t, err) + assert.Equal(t, []string{"services/5AF5-2C11-D467"}, spy.got) +}