From 6f4f3c4aacea8437d6e8a83d2c1d95255c1eddbb Mon Sep 17 00:00:00 2001 From: Maciej Lech Date: Fri, 31 Oct 2025 12:57:07 +0100 Subject: [PATCH] fix(sdn): fix subnet datasource Signed-off-by: Maciej Lech --- .../data_source_virtual_environment_sdn.tf | 50 +++++++++++++++++++ fwprovider/cluster/sdn/subnet/datasource.go | 4 ++ 2 files changed, 54 insertions(+) create mode 100644 example/data_source_virtual_environment_sdn.tf diff --git a/example/data_source_virtual_environment_sdn.tf b/example/data_source_virtual_environment_sdn.tf new file mode 100644 index 000000000..42553d178 --- /dev/null +++ b/example/data_source_virtual_environment_sdn.tf @@ -0,0 +1,50 @@ +data "proxmox_virtual_environment_sdn_zone_simple" "test_zone_1" { + depends_on = [proxmox_virtual_environment_sdn_zone_simple.test_zone_1] + id = proxmox_virtual_environment_sdn_zone_simple.test_zone_1.id +} + +data "proxmox_virtual_environment_sdn_zones" "simple" { + depends_on = [ + proxmox_virtual_environment_sdn_zone_simple.test_zone_1, + proxmox_virtual_environment_sdn_zone_simple.test_zone_2, + ] + type = "simple" +} + +data "proxmox_virtual_environment_sdn_zones" "all" { + depends_on = [ + proxmox_virtual_environment_sdn_zone_simple.test_zone_1, + proxmox_virtual_environment_sdn_zone_simple.test_zone_2, + ] +} + +data "proxmox_virtual_environment_sdn_vnet" "test_vnet_1" { + depends_on = [proxmox_virtual_environment_sdn_vnet.test_vnet_1] + id = proxmox_virtual_environment_sdn_vnet.test_vnet_1.id +} + +data "proxmox_virtual_environment_sdn_subnet" "test_subnet_dhcp" { + depends_on = [proxmox_virtual_environment_sdn_subnet.test_subnet_dhcp] + cidr = proxmox_virtual_environment_sdn_subnet.test_subnet_dhcp.cidr + vnet = proxmox_virtual_environment_sdn_vnet.test_vnet_1.id +} + +output "proxmox_virtual_environment_sdn_zone_simple" { + value = data.proxmox_virtual_environment_sdn_zone_simple.test_zone_1 +} + +output "proxmox_virtual_environment_sdn_zones_simple" { + value = data.proxmox_virtual_environment_sdn_zones.simple.zones +} + +output "proxmox_virtual_environment_sdn_zones_all" { + value = data.proxmox_virtual_environment_sdn_zones.all.zones +} + +output "proxmox_virtual_environment_sdn_vnet" { + value = data.proxmox_virtual_environment_sdn_vnet.test_vnet_1 +} + +output "proxmox_virtual_environment_sdn_subnet" { + value = data.proxmox_virtual_environment_sdn_subnet.test_subnet_dhcp +} diff --git a/fwprovider/cluster/sdn/subnet/datasource.go b/fwprovider/cluster/sdn/subnet/datasource.go index f1e3bcc14..7bb8e9d2f 100644 --- a/fwprovider/cluster/sdn/subnet/datasource.go +++ b/fwprovider/cluster/sdn/subnet/datasource.go @@ -74,6 +74,7 @@ func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp }, "dhcp_dns_server": schema.StringAttribute{ Description: "The DNS server used for DHCP.", + CustomType: customtypes.IPAddrType{}, Computed: true, }, "dhcp_range": schema.SingleNestedAttribute{ @@ -82,10 +83,12 @@ func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp Computed: true, Attributes: map[string]schema.Attribute{ "start_address": schema.StringAttribute{ + CustomType: customtypes.IPAddrType{}, Computed: true, Description: "Start of the DHCP range.", }, "end_address": schema.StringAttribute{ + CustomType: customtypes.IPAddrType{}, Computed: true, Description: "End of the DHCP range.", }, @@ -97,6 +100,7 @@ func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp }, "gateway": schema.StringAttribute{ Description: "The gateway address for the subnet.", + CustomType: customtypes.IPAddrType{}, Computed: true, }, "snat": schema.BoolAttribute{