Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new CLI command, scw account project list-resources, intended to list a project’s resources across zones/regions by calling multiple product APIs and aggregating the results into a unified fetch.ResourceResult view.
Changes:
- Added
account project list-resourcescommand implementation (zone/region de-duplication, concurrency limiting, sorting, and output view). - Introduced a new
internal/fetchabstraction plus many per-product “custom fetcher” implementations to list resources per service. - Added documentation and usage golden test fixtures for the new command.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/namespaces/account/v3/custom.go | Registers the new list-resources command under account project. |
| internal/namespaces/account/v3/custom_list_resources.go | Implements the new command, including fetcher registry, concurrency, de-duplication, and sorting. |
| internal/namespaces/account/v3/custom_list_resources_test.go | Adds unit tests for helper functions (query key building, resolvers, sorting). |
| internal/fetch/fetch.go | Adds generic/non-generic fetcher abstractions, result type, and error-ignoring helper. |
| internal/namespaces/instance/v1/custom_fetcher.go | Adds instance resource fetchers (servers, IPs, volumes, snapshots). |
| internal/namespaces/baremetal/v1/custom_fetcher.go | Adds baremetal server fetcher. |
| internal/namespaces/applesilicon/v1alpha1/custom_fetcher.go | Adds Apple Silicon server fetcher. |
| internal/namespaces/block/v1alpha1/custom_fetcher.go | Adds block volumes and snapshots fetchers. |
| internal/namespaces/object/v1/custom_fetcher.go | Adds S3-based bucket listing fetcher for Object Storage. |
| internal/namespaces/ipam/v1/custom_fetcher.go | Adds IPAM IP listing fetcher. |
| internal/namespaces/vpc/v2/custom_fetcher.go | Adds VPC listing fetcher. |
| internal/namespaces/vpcgw/v2/custom_fetcher.go | Adds VPC Gateway and Gateway IPs fetchers. |
| internal/namespaces/lb/v1/custom_fetcher.go | Adds load balancer listing fetcher. |
| internal/namespaces/k8s/v1/custom_fetcher.go | Adds Kubernetes cluster listing fetcher. |
| internal/namespaces/redis/v1/custom_fetcher.go | Adds Redis cluster listing fetcher. |
| internal/namespaces/rdb/v1/custom_fetcher.go | Adds RDB instance listing fetcher. |
| internal/namespaces/mongodb/v1alpha1/custom_fetcher.go | Adds MongoDB instance and snapshot listing fetchers. |
| internal/namespaces/registry/v1/custom_fetcher.go | Adds registry namespace listing fetcher. |
| internal/namespaces/container/v1/custom_fetcher.go | Adds container namespace listing fetcher. |
| internal/namespaces/function/v1beta1/custom_fetcher.go | Adds function namespace listing fetcher. |
| internal/namespaces/secret/v1beta1/custom_fetcher.go | Adds secret listing fetcher. |
| internal/namespaces/key_manager/v1alpha1/custom_fetcher.go | Adds key manager key listing fetcher. |
| internal/namespaces/file/v1alpha1/custom_fetcher.go | Adds file system listing fetcher. |
| internal/namespaces/webhosting/v1/custom_fetcher.go | Adds webhosting hosting listing fetcher. |
| internal/namespaces/inference/v1/custom_fetcher.go | Adds inference deployment listing fetcher. |
| internal/namespaces/cockpit/v1/custom_fetcher.go | Adds cockpit token and datasource listing fetchers. |
| internal/namespaces/flexibleip/v1alpha1/custom_fetcher.go | Adds flexible IP listing fetcher. |
| internal/namespaces/searchdb/v1alpha1/custom_fetcher.go | Adds SearchDB deployment listing fetcher. |
| docs/commands/account.md | Documents the new account project list-resources command. |
| cmd/scw/testdata/test-all-usage-account-project-usage.golden | Updates account project usage listing to include list-resources. |
| cmd/scw/testdata/test-all-usage-account-project-list-resources-usage.golden | Adds the usage golden file for account project list-resources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3a39735 to
9493767
Compare
| "registry-namespaces": fetch.WrapFetcher(®istry.FetchNamespaces{}), | ||
| "searchdb-deployments": fetch.WrapFetcher(&searchdb.FetchDeployments{}), | ||
| "s2s-vpn-vpn-gateway": fetch.WrapFetcher(&s2s_vpn.FetchVpnGateways{}), | ||
| } |
There was a problem hiding this comment.
Homogenize namings ? Some are plural, some singular, some match exactly product-resource but some do not (ie key-manager vs keymanager-key or rather keymanager-keys if we keep all plurals)
| Name: "products", | ||
| Short: `Filter by products (comma-separated: instances,instance-ips,instance-volumes,instance-snapshots,ipam,block-volumes,block-snapshots,buckets,rdb,redis,lb,k8s,containers,functions,flexibleip,secrets,vpc,file,webhosting,registry,searchdb,s2s-vpn-vpn-gateway). If empty, all products are queried`, | ||
| Required: false, | ||
| Deprecated: false, | ||
| Positional: false, |
There was a problem hiding this comment.
Currently accepts any value. Add validation if products is present?
| |------|---|-------------| | ||
| | project-id | Default: `` | Filter by project ID. If none is passed the default project ID will be used | | ||
| | zones | | Filter by zones (comma-separated, e.g. fr-par-1,nl-ams-1). If empty, all zones are queried | | ||
| | products | | Filter by products (comma-separated: instances,instance-ips,instance-volumes,instance-snapshots,ipam,block-volumes,block-snapshots,buckets,rdb,redis,lb,k8s,containers,functions,flexibleip,secrets,vpc,file,webhosting,registry,searchdb,s2s-vpn-vpn-gateway). If empty, all products are queried | |
There was a problem hiding this comment.
- This currently contains a mix of product names, resource names and non valid values
- Semantically, the filter seems to apply on resources and not products (ie a valid filter is
ipam-ipand notipamas a whole). Should there be an actual product filter ? Should this filter be renamed toresources?
|
|
||
| type FetchServers struct{} | ||
|
|
||
| func (s *FetchServers) Resource() string { |
There was a problem hiding this comment.
Why (func (s *Fetch...) Resource() string { instead of func (s Fetch...) Resource() string { like in most other namespaces ?
|
|
||
| type FetchServers struct{} | ||
|
|
||
| func (s *FetchServers) Resource() string { |
There was a problem hiding this comment.
Why (func (s *Fetch...) Resource() string { instead of func (s Fetch...) Resource() string { like in most other namespaces ?
|
|
||
| type FetchSnapshots struct{} | ||
|
|
||
| func (s *FetchSnapshots) Resource() string { |
There was a problem hiding this comment.
Why (func (s *Fetch...) Resource() string { instead of func (s Fetch...) Resource() string { like in most other namespaces ?
| // | ||
| // This map is needed because some products have different naming between | ||
| // their CLI namespace and their ProductFetchers key (e.g., "baremetal" -> "baremetal-servers"). | ||
| func getNamespaceToProductMap() map[string]string { |
There was a problem hiding this comment.
Can we add an e2e test that iterates on each entry, and filters on one product at a time to make the CLI calls, verifying that no API error occurs ? This would ensure that all product names are correct.
| // Create S3 client for use in the resources command. | ||
| s3Client := newS3ClientForResources(client, region) | ||
| if s3Client == nil { | ||
| return nil, nil |
There was a problem hiding this comment.
Not sure if this is a me issue, but scw account project list-resources products.0=object-buckets seems to always exit here without making any API call.
scw account project list-resources-> helpful if you context is a given project and you would like to understand what is inside