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