Skip to content

Commit

Permalink
fix: validator schema
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod committed Jun 15, 2023
1 parent 4451b40 commit 0b538eb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/resources/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Optional:
- `adapter_type` (String) The type of vNic to create on this interface. Value must be one of: `VMXNET3` (A VMXNET3 adapter it's an paravirtualized NIC designed for performance. VMXNET 3 offers all the features available in VMXNET 2 and adds several new features.), `E1000E` (A E1000E adapter it's an Emulated version of the Intel 82574 Gigabit Ethernet NIC. E1000E is the default adapter for Windows 8 and Windows Server 2012.), `VMXNET3VRDMA` (VMXNET3VRDMA adapter it's a paravirtualized NIC that supports remote direct memory access (RDMA) between virtual machines through the OFED verbs API.), `SRIOVETHERNETCARD` (SRIOVETHERNETCARD adapter it's a representation of a virtual function (VF) on a physical NIC with SR-IOV support.). Value defaults to `VMXNET3`.
- `connected` (Boolean) Whether the network interface is connected or not. Value defaults to `true`.
- `ip` (String) The IP address to assign to this VM on this network. Must be a valid IP with net.ParseIP. If <.ip_allocation_mode attribute is set and the value is one of `"MANUAL"`, `"POOL"`, this attribute is REQUIRED. If <.ip_allocation_mode attribute is set and the value is one of `"DHCP"`, `"NONE"`, this attribute is NULL.
- `ip_allocation_mode` (String) The IP allocation mode for this network. Value must be one of : `DHCP`, `POOL`, `MANUAL`, `NONE`. Value defaults to `DHCP`.
- `ip_allocation_mode` (String) The IP allocation mode for this network. Value must be one of: `DHCP` (IP address is obtained from a DHCP service.), `POOL` (Static IP address is allocated automatically from defined static pool in network.), `MANUAL` (SIP address is assigned manually in the ip field. Must be valid IP address from static pool.), `NONE` (No IP address will be set because VM will have a NIC without network.). Value defaults to `DHCP`.
- `is_primary` (Boolean) Whether this network is the primary network for the VM. Value defaults to `false`.
- `mac` (String) The MAC address to assign to this VM on this network. Autogenerated if not specified. Must be a valid mac address.
- `name` (String) The name of the network to attach to the VM. If <.type attribute is set and the value is one of `"vapp"`, `"org"`, this attribute is REQUIRED. If <.type attribute is set and the value is one of `"none"`, this attribute is NULL.
Expand Down Expand Up @@ -224,7 +224,7 @@ Optional:
- `join_domain_password` (String, Sensitive) The domain password to join.
- `join_domain_user` (String) The domain user to join.
- `join_org_domain` (Boolean) Use organization's domain for joining.
- `must_change_password_on_first_login` (Boolean) .
- `must_change_password_on_first_login` (Boolean) Whether the password must be changed on first login.
- `number_of_auto_logons` (Number) The number of times the VM should auto-login. Value must be at least 0.


Expand Down
2 changes: 1 addition & 1 deletion internal/provider/vm/vm_disk_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func DiskSuperSchema() superschema.Schema {
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{ // TODO: Miss the validation of the bus type if disk is detachable or not.
Validators: []validator.String{
stringvalidator.OneOf(diskparams.ListOfBusTypes...),
},
},
Expand Down
22 changes: 20 additions & 2 deletions internal/provider/vm/vm_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,24 @@ func vmSuperSchema(_ context.Context) superschema.Schema {
Optional: true,
Default: stringdefault.StaticString("DHCP"),
Validators: []validator.String{
stringvalidator.OneOf("DHCP", "POOL", "MANUAL", "NONE"),
fstringvalidator.OneOfWithDescription(
fstringvalidator.OneOfWithDescriptionValues{
Value: "DHCP",
Description: "IP address is obtained from a DHCP service.",
},
fstringvalidator.OneOfWithDescriptionValues{
Value: "POOL",
Description: "Static IP address is allocated automatically from defined static pool in network.",
},
fstringvalidator.OneOfWithDescriptionValues{
Value: "MANUAL",
Description: "SIP address is assigned manually in the ip field. Must be valid IP address from static pool.",
},
fstringvalidator.OneOfWithDescriptionValues{
Value: "NONE",
Description: "No IP address will be set because VM will have a NIC without network.",
},
),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
Expand Down Expand Up @@ -590,7 +607,8 @@ func vmSuperSchema(_ context.Context) superschema.Schema {
},
"must_change_password_on_first_login": superschema.BoolAttribute{
Resource: &schemaR.BoolAttribute{
Optional: true,
MarkdownDescription: "Whether the password must be changed on first login.",
Optional: true,
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
},
Expand Down

0 comments on commit 0b538eb

Please sign in to comment.