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

Change some resource arguments to required and add autodoc documentation #152

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions docs/data-sources/foreman_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ The following attributes are exported:
- `httpboot_id` - HTTPBoot Proxy ID to use within this subnet
- `ipam` - IP address auto-suggestion for this subnet. Valid values include: `"DHCP"`, `"Internal DB"`, `"Random DB"`,`"None"`.
- `mask` - Netmask for this subnet.
- `mtu` - MTU value for the subnet
- `mtu` - MTU value for the subnet.
- `name` - Name of a subnetwork.
- `network` - Subnet network.
- `network_address` - The Subnets CIDR in the format 169.254.0.0/16
- `network_type` - Type or protocol, IPv4 or IPv6, defaults to IPv4.
- `network_type` - Type or protocol, IPv4 or IPv6.
- `template_id` - Template HTTP(S) Proxy ID to use within this subnet
- `tftp_id` - TFTP Proxy ID to use within this subnet
- `to` - Ending IP address for IP auto suggestion.
Expand Down
16 changes: 10 additions & 6 deletions docs/resources/foreman_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Foreman representation of a subnetwork.
```
# Autogenerated example with required keys
resource "foreman_subnet" "example" {
boot_mode = "DHCP"
ipam = "DHCP"
mask = "255.255.255.0"
mtu = "1500"
name = "10.228.247.0 BO1"
network = "10.228.247.0"
network_type = "IPv4"
}
```

Expand All @@ -22,7 +26,7 @@ resource "foreman_subnet" "example" {
The following arguments are supported:

- `bmc_id` - (Optional) BMC Proxy ID to use within this subnet
- `boot_mode` - (Optional) Default boot mode for instances assigned to this subnet. Values include: `"Static"`, `"DHCP"`.
- `boot_mode` - (Required) Default boot mode for instances assigned to this subnet. Values include: `"Static"`, `"DHCP"`.
- `description` - (Optional) Description of the subnet
- `dhcp_id` - (Optional) DHCP Proxy ID to use within this subnet
- `dns_primary` - (Optional) Primary DNS server for this subnet.
Expand All @@ -31,13 +35,13 @@ The following arguments are supported:
- `from` - (Optional) Start IP address for IP auto suggestion.
- `gateway` - (Optional) Gateway server to use when connecting/communicating to anything not on the same network.
- `httpboot_id` - (Optional) HTTPBoot Proxy ID to use within this subnet
- `ipam` - (Optional) IP address auto-suggestion for this subnet. Valid values include: `"DHCP"`, `"Internal DB"`, `"Random DB"`,`"None"`.
- `ipam` - (Required) IP address auto-suggestion for this subnet. Valid values include: `"DHCP"`, `"Internal DB"`, `"Random DB"`,`"None"`.
- `mask` - (Required) Netmask for this subnet.
- `mtu` - (Optional) MTU value for the subnet
- `mtu` - (Required) MTU value for the subnet.
- `name` - (Required) Subnet name.
- `network` - (Required) Subnet network.
- `network_address` - (Optional) The Subnets CIDR in the format 169.254.0.0/16
- `network_type` - (Optional) Type or protocol, IPv4 or IPv6, defaults to IPv4.
- `network_type` - (Required) Type or protocol, IPv4 or IPv6.
- `template_id` - (Optional) Template HTTP(S) Proxy ID to use within this subnet
- `tftp_id` - (Optional) TFTP Proxy ID to use within this subnet
- `to` - (Optional) Ending IP address for IP auto suggestion.
Expand All @@ -60,11 +64,11 @@ The following attributes are exported:
- `httpboot_id` - HTTPBoot Proxy ID to use within this subnet
- `ipam` - IP address auto-suggestion for this subnet. Valid values include: `"DHCP"`, `"Internal DB"`, `"Random DB"`,`"None"`.
- `mask` - Netmask for this subnet.
- `mtu` - MTU value for the subnet
- `mtu` - MTU value for the subnet.
- `name` - Subnet name.
- `network` - Subnet network.
- `network_address` - The Subnets CIDR in the format 169.254.0.0/16
- `network_type` - Type or protocol, IPv4 or IPv6, defaults to IPv4.
- `network_type` - Type or protocol, IPv4 or IPv6.
- `template_id` - Template HTTP(S) Proxy ID to use within this subnet
- `tftp_id` - TFTP Proxy ID to use within this subnet
- `to` - Ending IP address for IP auto suggestion.
Expand Down
39 changes: 27 additions & 12 deletions foreman/resource_foreman_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,21 @@ func resourceForemanSubnet() *schema.Resource {

"ipam": {
Type: schema.TypeString,
Optional: true,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"DHCP",
"Internal DB",
"Random DB",
"None",
// NOTE(ALL): false - do not ignore case when comparing values
}, false),
Description: "IP address auto-suggestion for this subnet. Valid " +
"values include: `\"DHCP\"`, `\"Internal DB\"`, `\"Random DB\"`,`\"None\"`.",
Description: fmt.Sprintf(
"IP address auto-suggestion for this subnet. Valid "+
"values include: `\"DHCP\"`, `\"Internal DB\"`, `\"Random DB\"`,`\"None\"`."+
"%s \"DHCP\"",
autodoc.MetaExample,
),
},

"from": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -120,14 +123,18 @@ func resourceForemanSubnet() *schema.Resource {

"boot_mode": {
Type: schema.TypeString,
Optional: true,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"Static",
"DHCP",
// NOTE(ALL): false - do not ignore case when comparing values
}, false),
Description: "Default boot mode for instances assigned to this subnet. " +
"Values include: `\"Static\"`, `\"DHCP\"`.",
Description: fmt.Sprintf(
"Default boot mode for instances assigned to this subnet. "+
"Values include: `\"Static\"`, `\"DHCP\"`."+
"%s \"DHCP\"",
autodoc.MetaExample,
),
},
"network_address": {
Type: schema.TypeString,
Expand All @@ -140,9 +147,13 @@ func resourceForemanSubnet() *schema.Resource {
Description: "VLAN id that is in use in the subnet",
},
"mtu": {
Type: schema.TypeInt,
Optional: true,
Description: "MTU value for the subnet",
Type: schema.TypeInt,
Required: true,
Description: fmt.Sprintf(
"MTU value for the subnet. "+
"%s \"1500\"",
autodoc.MetaExample,
),
},
"template_id": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -179,12 +190,16 @@ func resourceForemanSubnet() *schema.Resource {
},
"network_type": {
Type: schema.TypeString,
Optional: true,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"IPv4",
"IPv6",
}, false),
Description: "Type or protocol, IPv4 or IPv6, defaults to IPv4.",
Description: fmt.Sprintf(
"Type or protocol, IPv4 or IPv6. "+
"%s \"IPv4\"",
autodoc.MetaExample,
),
},
"description": {
Type: schema.TypeString,
Expand Down
Loading