diff --git a/fwprovider/ha/resource_hagroup.go b/fwprovider/ha/resource_hagroup.go index 20981a5eb..6fa6344ef 100644 --- a/fwprovider/ha/resource_hagroup.go +++ b/fwprovider/ha/resource_hagroup.go @@ -70,7 +70,7 @@ func (r *hagroupResource) Schema( Required: true, Validators: []validator.String{ stringvalidator.RegexMatches( - regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\-_\.]*[a-zA-Z0-9]$`), + regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$`), "must start with a letter, end with a letter or number, be composed of "+ "letters, numbers, '-', '_' and '.', and must be at least 2 characters long", ), diff --git a/fwprovider/ha/resource_haresource.go b/fwprovider/ha/resource_haresource.go index 1616a0fbb..58629f82e 100644 --- a/fwprovider/ha/resource_haresource.go +++ b/fwprovider/ha/resource_haresource.go @@ -110,7 +110,7 @@ func (r *haResourceResource) Schema( Optional: true, Validators: []validator.String{ stringvalidator.RegexMatches( - regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\-_\.]*[a-zA-Z0-9]$`), + regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$`), "must start with a letter, end with a letter or number, be composed of "+ "letters, numbers, '-', '_' and '.', and must be at least 2 characters long", ), diff --git a/fwprovider/test/resource_file_test.go b/fwprovider/test/resource_file_test.go index b3da80b73..62bc54889 100644 --- a/fwprovider/test/resource_file_test.go +++ b/fwprovider/test/resource_file_test.go @@ -248,7 +248,9 @@ func uploadSnippetFile(t *testing.T, fileName string) { f, err := os.Open(fileName) require.NoError(t, err) - defer f.Close() + defer func(f *os.File) { + _ = f.Close() + }(f) fname := filepath.Base(fileName) err = sshClient.NodeStreamUpload(context.Background(), "pve", "/var/lib/vz/", @@ -269,7 +271,9 @@ func createFile(t *testing.T, namePattern string, content string) *os.File { _, err = f.WriteString(content) require.NoError(t, err) - defer f.Close() + defer func(f *os.File) { + _ = f.Close() + }(f) t.Cleanup(func() { _ = os.Remove(f.Name()) diff --git a/proxmox/nodes/vms/custom_vga_device.go b/proxmox/nodes/vms/custom_vga_device.go index 2e11ab72c..23963adef 100644 --- a/proxmox/nodes/vms/custom_vga_device.go +++ b/proxmox/nodes/vms/custom_vga_device.go @@ -22,7 +22,7 @@ type CustomVGADevice struct { } // EncodeValues converts a CustomVGADevice struct to a URL value. -func (r CustomVGADevice) EncodeValues(key string, v *url.Values) error { +func (r *CustomVGADevice) EncodeValues(key string, v *url.Values) error { var values []string if r.Clipboard != nil { diff --git a/proxmoxtf/resource/validators/file.go b/proxmoxtf/resource/validators/file.go index 6b016176a..c631e2065 100644 --- a/proxmoxtf/resource/validators/file.go +++ b/proxmoxtf/resource/validators/file.go @@ -50,7 +50,7 @@ func FileID() schema.SchemaValidateDiagFunc { } if v != "" { - r := regexp.MustCompile(`^(?i)[a-z\d\-_\.]+:([a-z\d\-_]+/)?.+$`) + r := regexp.MustCompile(`^(?i)[a-z\d\-_.]+:([a-z\d\-_]+/)?.+$`) ok := r.MatchString(v) if !ok { diff --git a/proxmoxtf/resource/vm/vm.go b/proxmoxtf/resource/vm/vm.go index e1e514960..e813e1722 100644 --- a/proxmoxtf/resource/vm/vm.go +++ b/proxmoxtf/resource/vm/vm.go @@ -89,7 +89,6 @@ const ( dvInitializationNetworkDataFileID = "" dvInitializationMetaDataFileID = "" dvInitializationType = "" - dvInitializationUpgrade = true dvKeyboardLayout = "en-us" dvKVMArguments = "" dvMachineType = "" @@ -1513,16 +1512,6 @@ func VM() *schema.Resource { } } -// ConvertToStringSlice helps convert interface slice to string slice. -func ConvertToStringSlice(interfaceSlice []interface{}) []string { - resultSlice := []string{} - for _, val := range interfaceSlice { - resultSlice = append(resultSlice, val.(string)) - } - - return resultSlice -} - func vmCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { clone := d.Get(mkClone).([]interface{}) @@ -2873,7 +2862,7 @@ func vmGetCloudInitConfig(d *schema.ResourceData) *vms.CustomCloudInitConfig { deprecatedServer := initializationDNSBlock[mkInitializationDNSServer].(string) if len(servers) > 0 { - nameserver := strings.Join(ConvertToStringSlice(servers), " ") + nameserver := strings.Join(utils.ConvertToStringSlice(servers), " ") initializationConfig.Nameserver = &nameserver } else if deprecatedServer != "" {