From 0233053dd8f8aa0fbfae8f7c11bb8ce359576bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 4 Sep 2023 22:11:14 +0200 Subject: [PATCH] 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. --- proxmoxtf/resource/validator/vm.go | 12 ++++++++++++ proxmoxtf/resource/vm.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/proxmoxtf/resource/validator/vm.go b/proxmoxtf/resource/validator/vm.go index 0c6cce98..e2201e6d 100644 --- a/proxmoxtf/resource/validator/vm.go +++ b/proxmoxtf/resource/validator/vm.go @@ -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{ diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go index 8eae9808..451ab98e 100644 --- a/proxmoxtf/resource/vm.go +++ b/proxmoxtf/resource/vm.go @@ -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 == "" },