Skip to content

Commit a0ca9f7

Browse files
authored
feat(ipam): support filtering ips on ids (scaleway#4351)
1 parent 013d224 commit a0ca9f7

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

cmd/scw/testdata/test-all-usage-ipam-ip-list-usage.golden

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ ARGS:
1313
[subnet-id] Subnet ID to filter for.
1414
[vpc-id] VPC ID to filter for.
1515
[attached] Defines whether to filter only for IPs which are attached to a resource
16+
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
1617
[resource-id] Resource ID to filter for. Only IPs attached to this resource will be returned
1718
[resource-ids.{index}] Resource IDs to filter for. Only IPs attached to at least one of these resources will be returned
1819
[resource-type] Resource type to filter for. Only IPs attached to this type of resource will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
20+
[resource-types.{index}] Resource types to filter for. Only IPs attached to these types of resources will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
1921
[mac-address] MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned
2022
[tags.{index}] Tags to filter for, only IPs with one or more matching tags will be returned
2123
[is-ipv6] Defines whether to filter only for IPv4s or IPv6s
22-
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
23-
[resource-types.{index}] Resource types to filter for. Only IPs attached to these types of resources will be returned (unknown_type | custom | instance_server | instance_ip | instance_private_nic | lb_server | fip_ip | vpc_gateway | vpc_gateway_network | k8s_node | k8s_cluster | rdb_instance | redis_cluster | baremetal_server | baremetal_private_nic | llm_deployment | mgdb_instance | apple_silicon_server | apple_silicon_private_nic)
24+
[ip-ids.{index}] IP IDs to filter for. Only IPs with these UUIDs will be returned
2425
[organization-id] Organization ID to filter for. Only IPs belonging to this Organization will be returned
2526
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all)
2627

docs/commands/ipam.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ scw ipam ip list [arg=value ...]
107107
| subnet-id | | Subnet ID to filter for. |
108108
| vpc-id | | VPC ID to filter for. |
109109
| attached | | Defines whether to filter only for IPs which are attached to a resource |
110+
| resource-name | | Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned. |
110111
| resource-id | | Resource ID to filter for. Only IPs attached to this resource will be returned |
111112
| resource-ids.{index} | | Resource IDs to filter for. Only IPs attached to at least one of these resources will be returned |
112113
| resource-type | One of: `unknown_type`, `custom`, `instance_server`, `instance_ip`, `instance_private_nic`, `lb_server`, `fip_ip`, `vpc_gateway`, `vpc_gateway_network`, `k8s_node`, `k8s_cluster`, `rdb_instance`, `redis_cluster`, `baremetal_server`, `baremetal_private_nic`, `llm_deployment`, `mgdb_instance`, `apple_silicon_server`, `apple_silicon_private_nic` | Resource type to filter for. Only IPs attached to this type of resource will be returned |
114+
| resource-types.{index} | One of: `unknown_type`, `custom`, `instance_server`, `instance_ip`, `instance_private_nic`, `lb_server`, `fip_ip`, `vpc_gateway`, `vpc_gateway_network`, `k8s_node`, `k8s_cluster`, `rdb_instance`, `redis_cluster`, `baremetal_server`, `baremetal_private_nic`, `llm_deployment`, `mgdb_instance`, `apple_silicon_server`, `apple_silicon_private_nic` | Resource types to filter for. Only IPs attached to these types of resources will be returned |
113115
| mac-address | | MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned |
114116
| tags.{index} | | Tags to filter for, only IPs with one or more matching tags will be returned |
115117
| is-ipv6 | | Defines whether to filter only for IPv4s or IPv6s |
116-
| resource-name | | Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned. |
117-
| resource-types.{index} | One of: `unknown_type`, `custom`, `instance_server`, `instance_ip`, `instance_private_nic`, `lb_server`, `fip_ip`, `vpc_gateway`, `vpc_gateway_network`, `k8s_node`, `k8s_cluster`, `rdb_instance`, `redis_cluster`, `baremetal_server`, `baremetal_private_nic`, `llm_deployment`, `mgdb_instance`, `apple_silicon_server`, `apple_silicon_private_nic` | Resource types to filter for. Only IPs attached to these types of resources will be returned |
118+
| ip-ids.{index} | | IP IDs to filter for. Only IPs with these UUIDs will be returned |
118119
| organization-id | | Organization ID to filter for. Only IPs belonging to this Organization will be returned |
119120
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw`, `all` | Region to target. If none is passed will use default region from the config |
120121

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/mattn/go-isatty v0.0.20
2727
github.com/moby/buildkit v0.13.2
2828
github.com/opencontainers/go-digest v1.0.0
29-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209103932-cb4590f1bf86
29+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209153125-92afa47368ef
3030
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3131
github.com/spf13/cobra v1.8.1
3232
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
466466
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
467467
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
468468
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
469-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209103932-cb4590f1bf86 h1:SA93A+shM43Qw7b8srntt5vp+hjuH3gEwRI7YDqZg3o=
470-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209103932-cb4590f1bf86/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks=
469+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209153125-92afa47368ef h1:WlyvzZzG1ipVvmolk69a7VdWCP5J0nCRxsNGpUspGrc=
470+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209153125-92afa47368ef/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks=
471471
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
472472
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
473473
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

internal/namespaces/ipam/v1/ipam_cli.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ func ipamIPList() *core.Command {
348348
Deprecated: false,
349349
Positional: false,
350350
},
351+
{
352+
Name: "resource-name",
353+
Short: `Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.`,
354+
Required: false,
355+
Deprecated: false,
356+
Positional: false,
357+
},
351358
{
352359
Name: "resource-id",
353360
Short: `Resource ID to filter for. Only IPs attached to this resource will be returned`,
@@ -370,6 +377,14 @@ func ipamIPList() *core.Command {
370377
Positional: false,
371378
EnumValues: []string{"unknown_type", "custom", "instance_server", "instance_ip", "instance_private_nic", "lb_server", "fip_ip", "vpc_gateway", "vpc_gateway_network", "k8s_node", "k8s_cluster", "rdb_instance", "redis_cluster", "baremetal_server", "baremetal_private_nic", "llm_deployment", "mgdb_instance", "apple_silicon_server", "apple_silicon_private_nic"},
372379
},
380+
{
381+
Name: "resource-types.{index}",
382+
Short: `Resource types to filter for. Only IPs attached to these types of resources will be returned`,
383+
Required: false,
384+
Deprecated: false,
385+
Positional: false,
386+
EnumValues: []string{"unknown_type", "custom", "instance_server", "instance_ip", "instance_private_nic", "lb_server", "fip_ip", "vpc_gateway", "vpc_gateway_network", "k8s_node", "k8s_cluster", "rdb_instance", "redis_cluster", "baremetal_server", "baremetal_private_nic", "llm_deployment", "mgdb_instance", "apple_silicon_server", "apple_silicon_private_nic"},
387+
},
373388
{
374389
Name: "mac-address",
375390
Short: `MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned`,
@@ -392,19 +407,11 @@ func ipamIPList() *core.Command {
392407
Positional: false,
393408
},
394409
{
395-
Name: "resource-name",
396-
Short: `Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.`,
397-
Required: false,
398-
Deprecated: false,
399-
Positional: false,
400-
},
401-
{
402-
Name: "resource-types.{index}",
403-
Short: `Resource types to filter for. Only IPs attached to these types of resources will be returned`,
410+
Name: "ip-ids.{index}",
411+
Short: `IP IDs to filter for. Only IPs with these UUIDs will be returned`,
404412
Required: false,
405413
Deprecated: false,
406414
Positional: false,
407-
EnumValues: []string{"unknown_type", "custom", "instance_server", "instance_ip", "instance_private_nic", "lb_server", "fip_ip", "vpc_gateway", "vpc_gateway_network", "k8s_node", "k8s_cluster", "rdb_instance", "redis_cluster", "baremetal_server", "baremetal_private_nic", "llm_deployment", "mgdb_instance", "apple_silicon_server", "apple_silicon_private_nic"},
408415
},
409416
{
410417
Name: "organization-id",

0 commit comments

Comments
 (0)