mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 11:02:59 +00:00
fix: rename ipset
block to cidr
This commit is contained in:
parent
3d14018ff7
commit
30560ac133
@ -18,19 +18,19 @@ resource "proxmox_virtual_environment_cluster_ipset" "ipset" {
|
||||
name = "local_network"
|
||||
comment = "Managed by Terraform"
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.0.0/23"
|
||||
cidr {
|
||||
name = "192.168.0.0/23"
|
||||
comment = "Local network 1"
|
||||
}
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.0.1"
|
||||
cidr {
|
||||
name = "192.168.0.1"
|
||||
comment = "Server 1"
|
||||
nomatch = true
|
||||
}
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.2.1"
|
||||
cidr {
|
||||
name = "192.168.2.1"
|
||||
comment = "Server 1"
|
||||
}
|
||||
}
|
||||
@ -40,8 +40,8 @@ resource "proxmox_virtual_environment_cluster_ipset" "ipset" {
|
||||
|
||||
* `name` - (Required) Alias name.
|
||||
* `comment` - (Optional) Alias comment.
|
||||
* `ipset` - (Optional) IP/CIDR block (multiple blocks supported).
|
||||
* `cidr` - Network/IP specification in CIDR format.
|
||||
* `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
|
||||
* `name` - Network/IP specification in CIDR format.
|
||||
* `comment` - (Optional) Arbitrary string annotation.
|
||||
* `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those were not added to the set.
|
||||
|
||||
|
@ -2,19 +2,19 @@ resource "proxmox_virtual_environment_cluster_ipset" "example" {
|
||||
name = "local_network"
|
||||
comment = "Managed by Terraform"
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.0.0/23"
|
||||
cidr {
|
||||
name = "192.168.0.0/23"
|
||||
comment = "Local network 1"
|
||||
}
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.0.1"
|
||||
cidr {
|
||||
name = "192.168.0.1"
|
||||
comment = "Server 1"
|
||||
nomatch = true
|
||||
}
|
||||
|
||||
ipset {
|
||||
cidr = "192.168.2.1"
|
||||
cidr {
|
||||
name = "192.168.2.1"
|
||||
comment = "Server 1"
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
dvResourceVirtualEnvironmentClusterIPSetComment = ""
|
||||
dvResourceVirtualEnvironmentClusterIPSetNoMatch = false
|
||||
dvResourceVirtualEnvironmentClusterIPSetCIDRComment = ""
|
||||
dvResourceVirtualEnvironmentClusterIPSetCIDRNoMatch = false
|
||||
|
||||
mkResourceVirtualEnvironmentClusterIPSet = "ipset"
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR = "cidr"
|
||||
mkResourceVirtualEnvironmentClusterIPSetName = "name"
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment = "comment"
|
||||
mkResourceVirtualEnvironmentClusterIPSetNoMatch = "nomatch"
|
||||
mkResourceVirtualEnvironmentClusterIPSetName = "name"
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR = "cidr"
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRName = "name"
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment = "comment"
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch = "nomatch"
|
||||
)
|
||||
|
||||
func resourceVirtualEnvironmentClusterIPSet() *schema.Resource {
|
||||
@ -30,7 +30,7 @@ func resourceVirtualEnvironmentClusterIPSet() *schema.Resource {
|
||||
Required: true,
|
||||
ForceNew: false,
|
||||
},
|
||||
mkResourceVirtualEnvironmentClusterIPSet: {
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR: {
|
||||
Type: schema.TypeList,
|
||||
Description: "List of IP or Networks",
|
||||
Optional: true,
|
||||
@ -40,34 +40,34 @@ func resourceVirtualEnvironmentClusterIPSet() *schema.Resource {
|
||||
},
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR: {
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRName: {
|
||||
Type: schema.TypeString,
|
||||
Description: "Network/IP specification in CIDR format",
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
mkResourceVirtualEnvironmentClusterIPSetNoMatch: {
|
||||
Type: schema.TypeBool,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: {
|
||||
Type: schema.TypeBool,
|
||||
Description: "No match this IP/CIDR",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetNoMatch,
|
||||
ForceNew: true,
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetCIDRNoMatch,
|
||||
ForceNew: true,
|
||||
},
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment: {
|
||||
Type: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: {
|
||||
Type: schema.TypeString,
|
||||
Description: "IP/CIDR comment",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetComment,
|
||||
ForceNew: true,
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetCIDRComment,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment: {
|
||||
Type: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: {
|
||||
Type: schema.TypeString,
|
||||
Description: "IPSet comment",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetComment,
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentClusterIPSetCIDRComment,
|
||||
},
|
||||
},
|
||||
Create: resourceVirtualEnvironmentClusterIPSetCreate,
|
||||
@ -85,19 +85,19 @@ func resourceVirtualEnvironmentClusterIPSetCreate(d *schema.ResourceData, m inte
|
||||
return err
|
||||
}
|
||||
|
||||
comment := d.Get(mkResourceVirtualEnvironmentClusterIPSetComment).(string)
|
||||
comment := d.Get(mkResourceVirtualEnvironmentClusterIPSetCIDRComment).(string)
|
||||
name := d.Get(mkResourceVirtualEnvironmentClusterIPSetName).(string)
|
||||
|
||||
IPSets := d.Get(mkResourceVirtualEnvironmentClusterIPSet).([]interface{})
|
||||
IPSets := d.Get(mkResourceVirtualEnvironmentClusterIPSetCIDR).([]interface{})
|
||||
IPSetsArray := make(proxmox.VirtualEnvironmentClusterIPSetContent, len(IPSets))
|
||||
|
||||
for i, v := range IPSets {
|
||||
IPSetMap := v.(map[string]interface{})
|
||||
IPSetObject := proxmox.VirtualEnvironmentClusterIPSetGetResponseData{}
|
||||
|
||||
cidr := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetCIDR].(string)
|
||||
noMatch := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetNoMatch].(bool)
|
||||
comment := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetComment].(string)
|
||||
cidr := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetCIDRName].(string)
|
||||
noMatch := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch].(bool)
|
||||
comment := IPSetMap[mkResourceVirtualEnvironmentClusterIPSetCIDRComment].(string)
|
||||
|
||||
|
||||
IPSetObject.Comment = comment
|
||||
@ -159,7 +159,7 @@ func resourceVirtualEnvironmentClusterIPSetRead(d *schema.ResourceData, m interf
|
||||
return err
|
||||
}
|
||||
|
||||
err = d.Set(mkResourceVirtualEnvironmentClusterIPSetComment, v.Comment)
|
||||
err = d.Set(mkResourceVirtualEnvironmentClusterIPSetCIDRComment, v.Comment)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -180,7 +180,7 @@ func resourceVirtualEnvironmentClusterIPSetRead(d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
for key, _ := range IPSet {
|
||||
d.Set(mkResourceVirtualEnvironmentClusterIPSet, IPSet[key])
|
||||
d.Set(mkResourceVirtualEnvironmentClusterIPSetCIDR, IPSet[key])
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -194,7 +194,7 @@ func resourceVirtualEnvironmentClusterIPSetUpdate(d *schema.ResourceData, m inte
|
||||
return err
|
||||
}
|
||||
|
||||
comment := d.Get(mkResourceVirtualEnvironmentClusterIPSetComment).(string)
|
||||
comment := d.Get(mkResourceVirtualEnvironmentClusterIPSetCIDRComment).(string)
|
||||
newName := d.Get(mkResourceVirtualEnvironmentClusterIPSetName).(string)
|
||||
previousName := d.Id()
|
||||
|
||||
|
@ -28,31 +28,31 @@ func TestResourceVirtualEnvironmentIPSetSchema(t *testing.T) {
|
||||
})
|
||||
|
||||
testOptionalArguments(t, s, []string{
|
||||
mkResourceVirtualEnvironmentClusterIPSet,
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment,
|
||||
})
|
||||
|
||||
testValueTypes(t, s, map[string]schema.ValueType{
|
||||
mkResourceVirtualEnvironmentClusterIPSetName: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSet: schema.TypeList,
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetName: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR: schema.TypeList,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
|
||||
})
|
||||
|
||||
IPSetSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentClusterIPSet)
|
||||
IPSetSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentClusterIPSetCIDR)
|
||||
|
||||
testRequiredArguments(t, IPSetSchema, []string{
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRName,
|
||||
})
|
||||
|
||||
testOptionalArguments(t, IPSetSchema, []string{
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment,
|
||||
mkResourceVirtualEnvironmentClusterIPSetNoMatch,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch,
|
||||
})
|
||||
|
||||
testValueTypes(t, IPSetSchema, map[string]schema.ValueType{
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDR: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetComment: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetNoMatch: schema.TypeBool,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRName: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: schema.TypeBool,
|
||||
})
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user