Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/require recent module #878

Merged
merged 8 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.19'
go-version: '1.20'
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.19'
go-version: '1.20'
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.19
go 1.20

require (
github.com/Telmate/proxmox-api-go v0.0.0-20231206132306-03715f935320
github.com/Telmate/proxmox-api-go v0.0.0-20231207182448-31826f2fdc39
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: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ 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-20231206132306-03715f935320 h1:PN6iyVbgsIUUxaYwn3peXYwrwXNVmDnBKZHYVYARW+o=
github.com/Telmate/proxmox-api-go v0.0.0-20231206132306-03715f935320/go.mod h1:xOwyTd8uC2IiYfmjwCVU2fTTVToFCm9yxJzn4cd7rPw=
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/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: 7 additions & 1 deletion proxmox/resource_storage_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ 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 @@ -96,7 +102,7 @@ func _downloadFile(url string, file *os.File) error {
}
defer resp.Body.Close()
_, err = io.Copy(file, resp.Body)
return nil
return err
}

func resourceStorageIsoRead(d *schema.ResourceData, meta interface{}) error {
Expand Down
13 changes: 5 additions & 8 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", key, v))
errs = append(errs, fmt.Errorf("%q, must be contain only alphanumerics and hyphens [%v]", key, v))
}
return
},
Expand Down Expand Up @@ -1069,16 +1069,15 @@ 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{})
targetNodes = make([]string, len(targetNodesRaw))
var targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

var targetNode string

if targetNodes == nil || len(targetNodes) == 0 {
if len(targetNodes) == 0 {
targetNode = d.Get("target_node").(string)
} else {
targetNode = targetNodes[rand.Intn(len(targetNodes))]
Expand Down Expand Up @@ -1668,14 +1667,13 @@ 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{})
targetNodes = make([]string, len(targetNodesRaw))
var targetNodes = make([]string, len(targetNodesRaw))
for i, raw := range targetNodesRaw {
targetNodes[i] = raw.(string)
}

if targetNodes == nil || len(targetNodes) == 0 {
if 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 @@ -1694,7 +1692,6 @@ 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