Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ipam): add support for custom resource #4079

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/scw/testdata/test-all-usage-ipam-ip-create-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARGS:
[is-ipv6] Request an IPv6 instead of an IPv4
[address] Request this specific IP address in the specified source pool
[tags.{index}] Tags for the IP
[resource.mac-address] MAC address of the custom resource
[resource.name] Name of the custom resource
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
Expand Down
4 changes: 2 additions & 2 deletions cmd/scw/testdata/test-all-usage-ipam-ip-list-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ ARGS:
[vpc-id] VPC ID to filter for.
[attached] Defines whether to filter only for IPs which are attached to a resource
[resource-id] Resource ID to filter for. Only IPs attached to this resource will be returned
[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)
[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)
[mac-address] MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned
[tags.{index}] Tags to filter for, only IPs with one or more matching tags will be returned
[is-ipv6] Defines whether to filter only for IPv4s or IPv6s
[resource-name] Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned.
[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)
[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)
[organization-id] Organization ID to filter for. Only IPs belonging to this Organization will be returned
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all)

Expand Down
6 changes: 4 additions & 2 deletions docs/commands/ipam.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ scw ipam ip create [arg=value ...]
| is-ipv6 | | Request an IPv6 instead of an IPv4 |
| address | | Request this specific IP address in the specified source pool |
| tags.{index} | | Tags for the IP |
| resource.mac-address | | MAC address of the custom resource |
| resource.name | | Name of the custom resource |
| 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 |


Expand Down Expand Up @@ -106,12 +108,12 @@ scw ipam ip list [arg=value ...]
| vpc-id | | VPC ID to filter for. |
| attached | | Defines whether to filter only for IPs which are attached to a resource |
| resource-id | | Resource ID to filter for. Only IPs attached to this resource will be returned |
| 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 |
| 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 |
| mac-address | | MAC address to filter for. Only IPs attached to a resource with this MAC address will be returned |
| tags.{index} | | Tags to filter for, only IPs with one or more matching tags will be returned |
| is-ipv6 | | Defines whether to filter only for IPv4s or IPv6s |
| resource-name | | Attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned. |
| 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 |
| 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 |
| organization-id | | Organization ID to filter for. Only IPs belonging to this Organization will be returned |
| 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 |

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/mattn/go-isatty v0.0.20
github.com/moby/buildkit v0.13.2
github.com/opencontainers/go-digest v1.0.0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240820123014-cf7d79e86f7e
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240820123014-cf7d79e86f7e h1:zHY4DTRBZTPm6Gm+Bs0l8xliPtuQNnha1cf2NQEWSUM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240820123014-cf7d79e86f7e/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14 h1:BxQQCTnvdpnhUJl1ICWeCKzV2Esbi3dGruIIk9xrDTk=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240823125746-1aae88e92d14/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=
Expand Down
18 changes: 16 additions & 2 deletions internal/namespaces/ipam/v1/ipam_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ func ipamIPCreate() *core.Command {
Deprecated: false,
Positional: false,
},
{
Name: "resource.mac-address",
Short: `MAC address of the custom resource`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "resource.name",
Short: `Name of the custom resource`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
Expand Down Expand Up @@ -347,7 +361,7 @@ func ipamIPList() *core.Command {
Required: false,
Deprecated: false,
Positional: false,
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"},
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"},
},
{
Name: "mac-address",
Expand Down Expand Up @@ -383,7 +397,7 @@ func ipamIPList() *core.Command {
Required: false,
Deprecated: false,
Positional: false,
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"},
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"},
},
{
Name: "organization-id",
Expand Down
Loading