Skip to content

Commit aabae46

Browse files
authored
feat(ipam): add support for custom resource (#4079)
1 parent 07162f1 commit aabae46

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ARGS:
1313
[is-ipv6] Request an IPv6 instead of an IPv4
1414
[address] Request this specific IP address in the specified source pool
1515
[tags.{index}] Tags for the IP
16+
[resource.mac-address] MAC address of the custom resource
17+
[resource.name] Name of the custom resource
1618
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
1719

1820
FLAGS:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ ARGS:
1414
[vpc-id] VPC ID to filter for.
1515
[attached] Defines whether to filter only for IPs which are attached to a resource
1616
[resource-id] Resource ID to filter for. Only IPs attached to this resource will be returned
17-
[resource-type] Resource type to filter for. Only IPs attached to this type of resource will be returned (unknown_type | 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)
17+
[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)
1818
[mac-address] MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned
1919
[tags.{index}] Tags to filter for, only IPs with one or more matching tags will be returned
2020
[is-ipv6] Defines whether to filter only for IPv4s or IPv6s
2121
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
22-
[resource-types.{index}] Resource types to filter for. Only IPs attached to these types of resources will be returned (unknown_type | 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)
22+
[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)
2323
[organization-id] Organization ID to filter for. Only IPs belonging to this Organization will be returned
2424
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all)
2525

docs/commands/ipam.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ scw ipam ip create [arg=value ...]
3939
| is-ipv6 | | Request an IPv6 instead of an IPv4 |
4040
| address | | Request this specific IP address in the specified source pool |
4141
| tags.{index} | | Tags for the IP |
42+
| resource.mac-address | | MAC address of the custom resource |
43+
| resource.name | | Name of the custom resource |
4244
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
4345

4446

@@ -106,12 +108,12 @@ scw ipam ip list [arg=value ...]
106108
| vpc-id | | VPC ID to filter for. |
107109
| attached | | Defines whether to filter only for IPs which are attached to a resource |
108110
| resource-id | | Resource ID to filter for. Only IPs attached to this resource will be returned |
109-
| resource-type | One of: `unknown_type`, `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` | Resource type to filter for. Only IPs attached to this type of resource will be returned |
111+
| 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` | Resource type to filter for. Only IPs attached to this type of resource will be returned |
110112
| mac-address | | MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned |
111113
| tags.{index} | | Tags to filter for, only IPs with one or more matching tags will be returned |
112114
| is-ipv6 | | Defines whether to filter only for IPv4s or IPv6s |
113115
| resource-name | | Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned. |
114-
| resource-types.{index} | One of: `unknown_type`, `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` | Resource types to filter for. Only IPs attached to these types of resources will be returned |
116+
| 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` | Resource types to filter for. Only IPs attached to these types of resources will be returned |
115117
| organization-id | | Organization ID to filter for. Only IPs belonging to this Organization will be returned |
116118
| 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 |
117119

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.29.0.20240820123014-cf7d79e86f7e
29+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14
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
@@ -469,8 +469,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
469469
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
470470
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
471471
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
472-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240820123014-cf7d79e86f7e h1:zHY4DTRBZTPm6Gm+Bs0l8xliPtuQNnha1cf2NQEWSUM=
473-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240820123014-cf7d79e86f7e/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
472+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14 h1:BxQQCTnvdpnhUJl1ICWeCKzV2Esbi3dGruIIk9xrDTk=
473+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
474474
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
475475
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
476476
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

internal/namespaces/ipam/v1/ipam_cli.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ func ipamIPCreate() *core.Command {
109109
Deprecated: false,
110110
Positional: false,
111111
},
112+
{
113+
Name: "resource.mac-address",
114+
Short: `MAC address of the custom resource`,
115+
Required: false,
116+
Deprecated: false,
117+
Positional: false,
118+
},
119+
{
120+
Name: "resource.name",
121+
Short: `Name of the custom resource`,
122+
Required: false,
123+
Deprecated: false,
124+
Positional: false,
125+
},
112126
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
113127
},
114128
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
@@ -347,7 +361,7 @@ func ipamIPList() *core.Command {
347361
Required: false,
348362
Deprecated: false,
349363
Positional: false,
350-
EnumValues: []string{"unknown_type", "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"},
364+
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"},
351365
},
352366
{
353367
Name: "mac-address",
@@ -383,7 +397,7 @@ func ipamIPList() *core.Command {
383397
Required: false,
384398
Deprecated: false,
385399
Positional: false,
386-
EnumValues: []string{"unknown_type", "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"},
400+
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"},
387401
},
388402
{
389403
Name: "organization-id",

0 commit comments

Comments
 (0)