Skip to content

Commit

Permalink
Revert "Bugfix/require recent module (Telmate#878)"
Browse files Browse the repository at this point in the history
This reverts commit a8675d3.
  • Loading branch information
MaartendeKruijf authored Dec 21, 2023
1 parent a8675d3 commit 9aa656f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.19'
check-latest: true

- name: Verify dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.19'
check-latest: true
-
name: Import GPG key
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/Telmate/terraform-provider-proxmox/v2

go 1.20
go 1.19

require (
github.com/Telmate/proxmox-api-go v0.0.0-20231207182448-31826f2fdc39
github.com/Telmate/proxmox-api-go v0.0.0-20231206132306-03715f935320
github.com/google/uuid v1.5.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/Telmate/proxmox-api-go v0.0.0-20231207182448-31826f2fdc39 h1:0MvktdAFWIcc9F4IwQls2Em1F9z2LUZR1fSVm1PkKfM=
github.com/Telmate/proxmox-api-go v0.0.0-20231207182448-31826f2fdc39/go.mod h1:xOwyTd8uC2IiYfmjwCVU2fTTVToFCm9yxJzn4cd7rPw=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/Telmate/proxmox-api-go v0.0.0-20231206132306-03715f935320 h1:PN6iyVbgsIUUxaYwn3peXYwrwXNVmDnBKZHYVYARW+o=
github.com/Telmate/proxmox-api-go v0.0.0-20231206132306-03715f935320/go.mod h1:xOwyTd8uC2IiYfmjwCVU2fTTVToFCm9yxJzn4cd7rPw=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
8 changes: 1 addition & 7 deletions proxmox/resource_storage_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ func resourceStorageIsoCreate(d *schema.ResourceData, meta interface{}) error {

client := pconf.Client
file, err := os.CreateTemp("/tmp", fileName)
if err != nil {
return err
}
err = _downloadFile(url, file)
if err != nil {
return err
}
file.Seek(0, 0)
defer file.Close()
err = client.Upload(node, storage, isoContentType, fileName, file)
Expand All @@ -102,7 +96,7 @@ func _downloadFile(url string, file *os.File) error {
}
defer resp.Body.Close()
_, err = io.Copy(file, resp.Body)
return err
return nil
}

func resourceStorageIsoRead(d *schema.ResourceData, meta interface{}) error {
Expand Down
13 changes: 8 additions & 5 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func resourceVmQemu() *schema.Resource {
warns = append(warns, fmt.Sprintf("%q, had an error running regexp.Match err=[%v]", key, err))
}
if matched {
errs = append(errs, fmt.Errorf("%q, must be contain only alphanumerics and hyphens [%v]", key, v))
errs = append(errs, fmt.Errorf("%q, must be contain only alphanumerics and hyphens", key, v))
}
return
},
Expand Down Expand Up @@ -1069,15 +1069,16 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte

forceCreate := d.Get("force_create").(bool)

var targetNodes []string
targetNodesRaw := d.Get("target_nodes").([]interface{})
var targetNodes = make([]string, len(targetNodesRaw))
targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

var targetNode string

if len(targetNodes) == 0 {
if targetNodes == nil || len(targetNodes) == 0 {
targetNode = d.Get("target_node").(string)
} else {
targetNode = targetNodes[rand.Intn(len(targetNodes))]
Expand Down Expand Up @@ -1667,13 +1668,14 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf

// loop through all virtual servers...?
var targetNodeVMR string = ""
var targetNodes []string
targetNodesRaw := d.Get("target_nodes").([]interface{})
var targetNodes = make([]string, len(targetNodesRaw))
targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

if len(targetNodes) == 0 {
if targetNodes == nil || len(targetNodes) == 0 {
_, err = client.GetVmInfo(vmr)
if err != nil {
logger.Debug().Int("vmid", vmID).Err(err).Msg("failed to get vm info")
Expand All @@ -1692,6 +1694,7 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf
d.SetId(resourceId(vmr.Node(), "qemu", vmr.VmId()))
logger.Debug().Any("Setting node id to", d.Get(vmr.Node()))
targetNodeVMR = targetNode
break
}
}

Expand Down
2 changes: 1 addition & 1 deletion proxmox/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MacAddressValidator() schema.SchemaValidateDiagFunc {
return diag.Errorf("expected type of %v to be string", k)
}
mac := strings.Replace(value, ":", "", -1)

// Check if a MAC address has been provided. If not, proxmox will generate random one.
if len(mac) == 0 {
return nil
Expand Down

0 comments on commit 9aa656f

Please sign in to comment.