0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-04 21:14:05 +00:00

fix(vm): explicitly allow "" as a value for CloudInit interfaces (#546)

The CloudInit interface can be left empty in order to allow
autodetection of the drive being used. However, it would seem that this
value was causing problems (see #539).

This commit adds an additional validator for CloudInit interfaces which
allows the `""` value.
This commit is contained in:
Emmanuel Benoît 2023-09-04 22:11:14 +02:00 committed by GitHub
parent 13326bbd33
commit 0233053dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -253,6 +253,18 @@ func IDEInterface() schema.SchemaValidateDiagFunc {
}, false))
}
// CloudInitInterface is a schema validation function that accepts either an IDE interface identifier or an
// empty string, which is used as the default and means "detect which interface should be used automatically".
func CloudInitInterface() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{
"",
"ide0",
"ide1",
"ide2",
"ide3",
}, false))
}
// CloudInitType is a schema validation function for cloud-init types.
func CloudInitType() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{

View File

@ -795,7 +795,7 @@ func VM() *schema.Resource {
Description: "The IDE interface on which the CloudInit drive will be added",
Optional: true,
Default: dvResourceVirtualEnvironmentVMInitializationInterface,
ValidateDiagFunc: validator.IDEInterface(),
ValidateDiagFunc: validator.CloudInitInterface(),
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
return newValue == ""
},