mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-09 15:25:01 +00:00
chore(deps): update golangci/golangci-lint (v2.1.6 → v2.2.1) (#2013)
* chore(deps): update golangci/golangci-lint (v2.1.6 → v2.2.1) | datasource | package | from | to | | --------------- | ---------------------- | ------ | ------ | | github-releases | golangci/golangci-lint | v2.1.6 | v2.2.1 | * chore: update rules & run linter Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
ebb0fc74af
commit
6a8f367c46
@ -1,6 +1,6 @@
|
||||
FROM golang:1.24.4@sha256:20a022e5112a144aa7b7aeb3f22ebf2cdaefcc4aac0d64e8deeee8cdc18b9c0f
|
||||
|
||||
ARG GOLANGCI_LINT_VERSION=2.1.6 # renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
ARG GOLANGCI_LINT_VERSION=2.2.1 # renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
|
||||
RUN apt update && apt upgrade -y && \
|
||||
apt-get install --no-install-recommends -y ca-certificates curl gnupg lsb-release jq zsh neovim gh && \
|
||||
|
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
@ -42,6 +42,6 @@ jobs:
|
||||
if: ${{ steps.filter.outputs.go == 'true' || steps.filter.outputs.linter == 'true'}}
|
||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
|
||||
with:
|
||||
version: v2.1.6 # renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
version: v2.2.1 # renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
skip-cache: true
|
||||
args: -v --timeout=10m
|
||||
|
@ -17,6 +17,7 @@ linters:
|
||||
- mnd
|
||||
- nestif
|
||||
- nlreturn
|
||||
- noinlineerr
|
||||
- perfsprint
|
||||
- rowserrcheck
|
||||
- tagliatelle
|
||||
@ -24,6 +25,7 @@ linters:
|
||||
- tparallel
|
||||
- varnamelen
|
||||
- wastedassign
|
||||
- wsl
|
||||
settings:
|
||||
cyclop:
|
||||
max-complexity: 25
|
||||
@ -49,6 +51,10 @@ linters:
|
||||
wrapcheck:
|
||||
ignore-package-globs:
|
||||
- github.com/bpg/terraform-provider-proxmox/*
|
||||
wsl_v5:
|
||||
allow-first-in-block: true
|
||||
allow-whole-block: false
|
||||
branch-max-lines: 2
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ TARGETS=darwin linux windows
|
||||
TERRAFORM_PLUGIN_EXTENSION=
|
||||
VERSION=0.78.2# x-release-please-version
|
||||
|
||||
GOLANGCI_LINT_VERSION=2.1.6# renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
GOLANGCI_LINT_VERSION=2.2.1# renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||
|
||||
# check if opentofu is installed and use it if it is,
|
||||
# otherwise use terraform
|
||||
|
@ -190,6 +190,7 @@ func (r *userTokenResource) Create(ctx context.Context, req resource.CreateReque
|
||||
|
||||
func (r *userTokenResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
|
||||
var state userTokenModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
|
@ -32,12 +32,14 @@ type baseACMEPluginModel struct {
|
||||
// acmePluginModel maps the schema data for an ACME plugin.
|
||||
type acmePluginModel struct {
|
||||
baseACMEPluginModel
|
||||
|
||||
Type types.String `tfsdk:"type"`
|
||||
}
|
||||
|
||||
// acmePluginCreateModel maps the schema data for an ACME plugin.
|
||||
type acmePluginCreateModel struct {
|
||||
baseACMEPluginModel
|
||||
|
||||
// Flag to disable the config
|
||||
Disable types.Bool `tfsdk:"disable"`
|
||||
}
|
||||
|
@ -719,6 +719,7 @@ func (r *clusterOptionsResource) Create(
|
||||
resp *resource.CreateResponse,
|
||||
) {
|
||||
var plan clusterOptionsModel
|
||||
|
||||
diags := req.Plan.Get(ctx, &plan)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -776,6 +777,7 @@ func (r *clusterOptionsResource) read(ctx context.Context, model *clusterOptions
|
||||
func (r *clusterOptionsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
|
||||
// Get current state
|
||||
var state clusterOptionsModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -899,6 +901,7 @@ func (r *clusterOptionsResource) Delete(
|
||||
resp *resource.DeleteResponse,
|
||||
) {
|
||||
var state clusterOptionsModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
|
@ -268,6 +268,7 @@ func (r *linuxBridgeResource) Configure(
|
||||
//nolint:dupl
|
||||
func (r *linuxBridgeResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
|
||||
var plan linuxBridgeResourceModel
|
||||
|
||||
diags := req.Plan.Get(ctx, &plan)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -355,6 +356,7 @@ func (r *linuxBridgeResource) read(ctx context.Context, model *linuxBridgeResour
|
||||
func (r *linuxBridgeResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
|
||||
// Get current state
|
||||
var state linuxBridgeResourceModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -461,6 +463,7 @@ func (r *linuxBridgeResource) Update(ctx context.Context, req resource.UpdateReq
|
||||
//nolint:dupl
|
||||
func (r *linuxBridgeResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
|
||||
var state linuxBridgeResourceModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
|
@ -240,6 +240,7 @@ func (r *linuxVLANResource) Configure(
|
||||
//nolint:dupl
|
||||
func (r *linuxVLANResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
|
||||
var plan linuxVLANResourceModel
|
||||
|
||||
diags := req.Plan.Get(ctx, &plan)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -319,6 +320,7 @@ func (r *linuxVLANResource) read(ctx context.Context, model *linuxVLANResourceMo
|
||||
func (r *linuxVLANResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
|
||||
// Get current state
|
||||
var state linuxVLANResourceModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -409,6 +411,7 @@ func (r *linuxVLANResource) Update(ctx context.Context, req resource.UpdateReque
|
||||
//nolint:dupl
|
||||
func (r *linuxVLANResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
|
||||
var state linuxVLANResourceModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
|
@ -323,6 +323,7 @@ func (r *downloadFileResource) Create(
|
||||
resp *resource.CreateResponse,
|
||||
) {
|
||||
var plan downloadFileModel
|
||||
|
||||
diags := req.Plan.Get(ctx, &plan)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
@ -370,7 +371,6 @@ func (r *downloadFileResource) Create(
|
||||
storageClient := nodesClient.Storage(plan.Storage.ValueString())
|
||||
|
||||
err = storageClient.DownloadFileByURL(ctx, &downloadFileReq)
|
||||
|
||||
if isErrFileAlreadyExists(err) && plan.OverwriteUnmanaged.ValueBool() {
|
||||
fileID := plan.Content.ValueString() + "/" + plan.FileName.ValueString()
|
||||
|
||||
@ -481,6 +481,7 @@ func (r *downloadFileResource) Read(
|
||||
resp *resource.ReadResponse,
|
||||
) {
|
||||
var state downloadFileModel
|
||||
|
||||
diags := req.State.Get(ctx, &state)
|
||||
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
@ -49,6 +49,7 @@ func FillCreateBody(ctx context.Context, planValue Value, body *vms.CreateReques
|
||||
}
|
||||
|
||||
var plan map[string]Model
|
||||
|
||||
d := planValue.ElementsAs(ctx, &plan, false)
|
||||
diags.Append(d...)
|
||||
|
||||
@ -76,6 +77,7 @@ func FillUpdateBody(
|
||||
}
|
||||
|
||||
var plan, state map[string]Model
|
||||
|
||||
d := planValue.ElementsAs(ctx, &plan, false)
|
||||
diags.Append(d...)
|
||||
d = stateValue.ElementsAs(ctx, &state, false)
|
||||
|
@ -265,6 +265,7 @@ func (p *proxmoxProvider) Configure(
|
||||
|
||||
// Retrieve provider data from configuration
|
||||
var cfg proxmoxProviderModel
|
||||
|
||||
diags := req.Config.Get(ctx, &cfg)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
||||
|
@ -195,6 +195,7 @@ func (e *Environment) RenderConfig(cfg string, opt ...RenderConfigOption) string
|
||||
require.NoError(e.t, err)
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
err = tmpl.Execute(&buf, e.templateVars)
|
||||
require.NoError(e.t, err)
|
||||
|
||||
|
@ -50,6 +50,7 @@ var (
|
||||
// PathType is a type that represents a path of a hardware mapping.
|
||||
type PathType struct {
|
||||
basetypes.StringType
|
||||
|
||||
Type proxmoxtypes.Type
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,8 @@ func TestPathValueFromTerraform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := t.Context()
|
||||
val, err := PathType{}.ValueFromTerraform(ctx, test.val)
|
||||
|
||||
val, err := PathType{}.ValueFromTerraform(ctx, test.val)
|
||||
if err == nil && test.expectError {
|
||||
t.Fatal("expected error, got no error")
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ func Test_IPAddrTypeValueFromTerraform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := t.Context()
|
||||
val, err := IPAddrType{}.ValueFromTerraform(ctx, test.val)
|
||||
|
||||
val, err := IPAddrType{}.ValueFromTerraform(ctx, test.val)
|
||||
if err == nil && test.expectError {
|
||||
t.Fatal("expected error, got no error")
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ func Test_IPCIDRTypeValueFromTerraform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := t.Context()
|
||||
val, err := IPCIDRType{}.ValueFromTerraform(ctx, test.val)
|
||||
|
||||
val, err := IPCIDRType{}.ValueFromTerraform(ctx, test.val)
|
||||
if err == nil && test.expectError {
|
||||
t.Fatal("expected error, got no error")
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ type StandardRepoHandleType struct {
|
||||
// StandardRepoHandleValue is a type that represents the value of an APT standard repository handle.
|
||||
type StandardRepoHandleValue struct {
|
||||
basetypes.StringValue
|
||||
|
||||
cvn apitypes.CephVersionName
|
||||
kind apitypes.StandardRepoHandleKind
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ func TestStandardRepoHandleValueFromTerraform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := t.Context()
|
||||
val, err := StandardRepoHandleType{}.ValueFromTerraform(ctx, test.val)
|
||||
|
||||
val, err := StandardRepoHandleType{}.ValueFromTerraform(ctx, test.val)
|
||||
if err == nil && test.expectError {
|
||||
t.Fatal("expected error, got no error")
|
||||
}
|
||||
|
@ -332,8 +332,8 @@ func validateResponseCode(res *http.Response) error {
|
||||
msg := strings.TrimPrefix(res.Status, fmt.Sprintf("%d ", res.StatusCode))
|
||||
|
||||
errRes := &ErrorResponseBody{}
|
||||
err := json.NewDecoder(res.Body).Decode(errRes)
|
||||
|
||||
err := json.NewDecoder(res.Body).Decode(errRes)
|
||||
if err == nil && errRes.Errors != nil {
|
||||
var errList []string
|
||||
|
||||
|
@ -35,6 +35,7 @@ type ACMEPluginsListResponseBody struct {
|
||||
// ACMEPluginsListResponseData contains the data from an ACME plugins list response.
|
||||
type ACMEPluginsListResponseData struct {
|
||||
BaseACMEPluginData
|
||||
|
||||
// ACME Plugin ID name
|
||||
Plugin string `json:"plugin" url:"plugin"`
|
||||
// DNS plugin data.
|
||||
@ -49,6 +50,7 @@ type ACMEPluginsGetResponseBody struct {
|
||||
// ACMEPluginsGetResponseData contains the data from an ACME plugins get response.
|
||||
type ACMEPluginsGetResponseData struct {
|
||||
BaseACMEPluginData
|
||||
|
||||
// ACME Plugin ID name
|
||||
Plugin string `json:"plugin" url:"plugin"`
|
||||
// DNS plugin data.
|
||||
@ -58,6 +60,7 @@ type ACMEPluginsGetResponseData struct {
|
||||
// ACMEPluginsCreateRequestBody contains the body for creating a new ACME plugin.
|
||||
type ACMEPluginsCreateRequestBody struct {
|
||||
BaseACMEPluginData
|
||||
|
||||
// ACME Plugin ID name
|
||||
Plugin string `json:"id" url:"id"`
|
||||
// DNS plugin data. (base64 encoded)
|
||||
@ -69,6 +72,7 @@ type ACMEPluginsCreateRequestBody struct {
|
||||
// ACMEPluginsUpdateRequestBody contains the body for updating an existing ACME plugin.
|
||||
type ACMEPluginsUpdateRequestBody struct {
|
||||
BaseACMEPluginData
|
||||
|
||||
// DNS plugin data. (base64 encoded)
|
||||
Data *DNSPluginData `url:"data,omitempty"`
|
||||
// A list of settings you want to delete.
|
||||
|
@ -27,6 +27,7 @@ type Client struct {
|
||||
|
||||
type groupClient struct {
|
||||
firewall.Client
|
||||
|
||||
Group string
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ type HAGroupDataBase struct {
|
||||
type HAGroupGetResponseData struct {
|
||||
// The group's data
|
||||
HAGroupDataBase
|
||||
|
||||
// The group's identifier
|
||||
ID string `json:"group"`
|
||||
// The type. Always set to `group`.
|
||||
@ -54,6 +55,7 @@ type HAGroupGetResponseData struct {
|
||||
type HAGroupCreateRequestBody struct {
|
||||
// The group's data
|
||||
HAGroupDataBase
|
||||
|
||||
// The group's identifier
|
||||
ID string `url:"group"`
|
||||
// The type. Always set to `group`.
|
||||
@ -64,6 +66,7 @@ type HAGroupCreateRequestBody struct {
|
||||
type HAGroupUpdateRequestBody struct {
|
||||
// The group's data
|
||||
HAGroupDataBase
|
||||
|
||||
// A list of settings to delete
|
||||
Delete string `url:"delete"`
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ type HAResourceDataBase struct {
|
||||
// HA resource.
|
||||
type HAResourceGetResponseData struct {
|
||||
HAResourceDataBase
|
||||
|
||||
// Identifier of this resource
|
||||
ID types.HAResourceID `json:"sid"`
|
||||
// Type of this resource
|
||||
@ -54,6 +55,7 @@ type HAResourceGetResponseData struct {
|
||||
// HAResourceCreateRequestBody contains data received from the HA resource API when creating a new HA resource.
|
||||
type HAResourceCreateRequestBody struct {
|
||||
HAResourceDataBase
|
||||
|
||||
// Identifier of this resource
|
||||
ID types.HAResourceID `url:"sid"`
|
||||
// Type of this resource
|
||||
@ -65,6 +67,7 @@ type HAResourceCreateRequestBody struct {
|
||||
// HAResourceUpdateRequestBody contains data received from the HA resource API when updating an existing HA resource.
|
||||
type HAResourceUpdateRequestBody struct {
|
||||
HAResourceDataBase
|
||||
|
||||
// Settings that must be deleted from the resource's configuration
|
||||
Delete []string `url:"delete,omitempty,comma"`
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ func (g IDGenerator) NextID(ctx context.Context) (int, error) {
|
||||
|
||||
if !g.config.RandomIDs {
|
||||
var b bytes.Buffer
|
||||
|
||||
_, _ = fmt.Fprintf(&b, "%d", *id)
|
||||
|
||||
if err := lockedfile.Write(g.config.seqFName, &b, 0o666); err != nil {
|
||||
|
@ -43,5 +43,6 @@ type ServersResponseBody struct {
|
||||
// ServerRequestData contains the data for a metric server post/put request.
|
||||
type ServerRequestData struct {
|
||||
ServerData
|
||||
|
||||
Delete *[]string `url:"delete,omitempty"`
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ type OptionsResponseBody struct {
|
||||
// OptionsResponseData contains the data from a cluster options response.
|
||||
type OptionsResponseData struct {
|
||||
optionsBaseData
|
||||
|
||||
MaxWorkers *types.CustomInt64 `json:"max_workers,omitempty"`
|
||||
ClusterResourceScheduling *crs `json:"crs,omitempty"`
|
||||
HASettings *haSettings `json:"ha,omitempty"`
|
||||
@ -83,6 +84,7 @@ type OptionsResponseData struct {
|
||||
// OptionsRequestData contains the body for cluster options request.
|
||||
type OptionsRequestData struct {
|
||||
optionsBaseData
|
||||
|
||||
MaxWorkers *int64 `json:"max_workers,omitempty" url:"max_workers,omitempty"`
|
||||
Delete *string `json:"delete,omitempty" url:"delete,omitempty"`
|
||||
ClusterResourceScheduling *string `json:"crs,omitempty" url:"crs,omitempty"`
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
// Client is an interface for accessing the Proxmox node API.
|
||||
type Client struct {
|
||||
api.Client
|
||||
|
||||
NodeName string
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
// Client is an interface for accessing the Proxmox container API.
|
||||
type Client struct {
|
||||
api.Client
|
||||
|
||||
VMID int
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,6 @@ func (c *Client) WaitForContainerStatus(ctx context.Context, status string) erro
|
||||
retry.Delay(1*time.Second),
|
||||
retry.LastErrorOnly(true),
|
||||
)
|
||||
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("timeout while waiting for container %d to enter the status %q", c.VMID, status)
|
||||
}
|
||||
@ -273,7 +272,6 @@ func (c *Client) WaitForContainerConfigUnlock(ctx context.Context, ignoreErrorRe
|
||||
retry.Delay(1*time.Second),
|
||||
retry.LastErrorOnly(true),
|
||||
)
|
||||
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("timeout while waiting for container %d configuration to become unlocked", c.VMID)
|
||||
}
|
||||
|
@ -636,6 +636,7 @@ func (r *CustomFeatures) UnmarshalJSON(b []byte) error {
|
||||
r.MountTypes = &a
|
||||
} else {
|
||||
var a []string
|
||||
|
||||
r.MountTypes = &a
|
||||
}
|
||||
case "nesting":
|
||||
@ -728,6 +729,7 @@ func (r *CustomMountPoint) UnmarshalJSON(b []byte) error {
|
||||
r.MountOptions = &a
|
||||
} else {
|
||||
var a []string
|
||||
|
||||
r.MountOptions = &a
|
||||
}
|
||||
case "mp":
|
||||
@ -827,6 +829,7 @@ func (r *CustomNetworkInterface) UnmarshalJSON(b []byte) error {
|
||||
r.Trunks = &a
|
||||
} else {
|
||||
var a []int
|
||||
|
||||
r.Trunks = &a
|
||||
}
|
||||
case "type":
|
||||
@ -865,6 +868,7 @@ func (r *CustomRootFS) UnmarshalJSON(b []byte) error {
|
||||
r.MountOptions = &a
|
||||
} else {
|
||||
var a []string
|
||||
|
||||
r.MountOptions = &a
|
||||
}
|
||||
case "quota":
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
// Client is an interface for accessing the Proxmox node storage API.
|
||||
type Client struct {
|
||||
api.Client
|
||||
|
||||
StorageName string
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,6 @@ func (c *Client) WaitForTask(ctx context.Context, upid string, opts ...TaskWaitO
|
||||
retry.DelayType(retry.FixedDelay),
|
||||
retry.Delay(time.Second),
|
||||
)
|
||||
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("timeout while waiting for task %q to complete", upid)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
// Client is an interface for accessing the Proxmox VM API.
|
||||
type Client struct {
|
||||
api.Client
|
||||
|
||||
VMID int
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ func (r *CustomCPUEmulation) UnmarshalJSON(b []byte) error {
|
||||
r.Flags = &f
|
||||
} else {
|
||||
var f []string
|
||||
|
||||
r.Flags = &f
|
||||
}
|
||||
case "hidden":
|
||||
|
@ -36,6 +36,7 @@ func (r *CustomVirtiofsShare) EncodeValues(key string, v *url.Values) error {
|
||||
}
|
||||
|
||||
var values []string
|
||||
|
||||
values = append(values, fmt.Sprintf("dirid=%s", r.DirId))
|
||||
|
||||
if r.Cache != nil {
|
||||
|
@ -675,7 +675,6 @@ func (c *Client) WaitForVMConfigUnlock(ctx context.Context, ignoreErrorResponse
|
||||
return errors.Is(err, stillLocked) || ignoreErrorResponse
|
||||
}),
|
||||
)
|
||||
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("timeout while waiting for VM %d configuration to become unlocked", c.VMID)
|
||||
}
|
||||
@ -714,7 +713,6 @@ func (c *Client) WaitForVMStatus(ctx context.Context, status string) error {
|
||||
return errors.Is(err, unexpectedStatus)
|
||||
}),
|
||||
)
|
||||
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("timeout while waiting for VM %d to enter the status %q", c.VMID, status)
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ func TestUnmarshalGetResponseData(t *testing.T) {
|
||||
}`, "local-lvm:vm-100-disk-0,aio=io_uring,backup=1,cache=none,discard=ignore,replicate=1,size=8G,ssd=1")
|
||||
|
||||
var data GetResponseData
|
||||
|
||||
err := json.Unmarshal([]byte(jsonData), &data)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -515,6 +515,7 @@ func (c *client) openNodeShell(ctx context.Context, node ProxmoxNode) (*ssh.Clie
|
||||
f, fErr := os.OpenFile(khPath, os.O_APPEND|os.O_WRONLY, 0o600)
|
||||
if fErr == nil {
|
||||
defer utils.CloseOrLogError(ctx)(f)
|
||||
|
||||
fErr = knownhosts.WriteKnownHost(f, hostname, remote, key)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@ func TestParseDiskSize(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := ParseDiskSize(tt.size)
|
||||
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseDiskSize() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
|
@ -51,6 +51,7 @@ func dnsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -78,12 +78,14 @@ func groupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
groupID := d.Get(mkDataSourceVirtualEnvironmentGroupID).(string)
|
||||
|
||||
group, err := api.Access().GetGroup(ctx, groupID)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -45,6 +45,7 @@ func groupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -85,6 +85,7 @@ func hostsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -95,6 +95,7 @@ func nodesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -83,12 +83,14 @@ func poolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
poolID := d.Get(mkDataSourceVirtualEnvironmentPoolPoolID).(string)
|
||||
|
||||
pool, err := api.Pool().GetPool(ctx, poolID)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -36,6 +36,7 @@ func Pools() *schema.Resource {
|
||||
|
||||
func poolsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -42,12 +42,14 @@ func Role() *schema.Resource {
|
||||
|
||||
func roleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
roleID := d.Get(mkDataSourceVirtualEnvironmentRoleID).(string)
|
||||
|
||||
accessRole, err := api.Access().GetRole(ctx, roleID)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -55,6 +55,7 @@ func rolesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -57,12 +57,14 @@ func timeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
nodeName := d.Get(mkDataSourceVirtualEnvironmentTimeNodeName).(string)
|
||||
|
||||
nodeTime, err := api.Node(nodeName).GetTime(ctx)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -115,12 +115,14 @@ func userRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
userID := d.Get(mkDataSourceVirtualEnvironmentUserUserID).(string)
|
||||
|
||||
v, err := api.Access().GetUser(ctx, userID)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -98,6 +98,7 @@ func usersRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -174,6 +174,7 @@ func certificateRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -303,6 +304,7 @@ func certificateRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
|
||||
func certificateUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -322,6 +324,7 @@ func certificateUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
func certificateDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -112,6 +112,7 @@ func dnsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -153,6 +154,7 @@ func dnsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di
|
||||
|
||||
func dnsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -603,6 +603,7 @@ func fileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
}
|
||||
|
||||
volID, di := fileGetVolumeID(ctx, d, capi)
|
||||
|
||||
diags = append(diags, di...)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
@ -763,6 +764,7 @@ func fileIsURL(d *schema.ResourceData) bool {
|
||||
|
||||
func fileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
capi, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -912,6 +914,7 @@ func readURL(
|
||||
|
||||
if httpLastModified != "" {
|
||||
var timeParsed time.Time
|
||||
|
||||
timeParsed, err = time.Parse(time.RFC1123, httpLastModified)
|
||||
if err != nil {
|
||||
timeParsed, err = time.Parse(time.RFC1123Z, httpLastModified)
|
||||
@ -939,6 +942,7 @@ func readURL(
|
||||
|
||||
func fileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
capi, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -204,6 +204,7 @@ func RulesCreate(ctx context.Context, api firewall.Rule, d *schema.ResourceData)
|
||||
if a == "" || t == "" {
|
||||
diags = append(diags, diag.Errorf("Either '%s' OR both '%s' and '%s' must be defined for the rule #%d",
|
||||
mkSecurityGroup, mkRuleAction, mkRuleType, i)...)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,7 @@ func Group() *schema.Resource {
|
||||
|
||||
func groupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -144,12 +145,14 @@ func groupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
groupID := d.Id()
|
||||
|
||||
group, err := client.Access().GetGroup(ctx, groupID)
|
||||
if err != nil {
|
||||
if errors.Is(err, api.ErrResourceDoesNotExist) {
|
||||
@ -203,6 +206,7 @@ func groupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
|
||||
func groupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -272,6 +276,7 @@ func groupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) dia
|
||||
|
||||
func groupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -141,6 +141,7 @@ func hostsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -210,6 +211,7 @@ func hostsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.
|
||||
|
||||
func hostsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -103,6 +103,7 @@ func Pool() *schema.Resource {
|
||||
|
||||
func poolCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -130,12 +131,14 @@ func poolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
poolID := d.Id()
|
||||
|
||||
pool, err := client.Pool().GetPool(ctx, poolID)
|
||||
if err != nil {
|
||||
if errors.Is(err, api.ErrResourceDoesNotExist) {
|
||||
@ -185,6 +188,7 @@ func poolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
|
||||
func poolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -207,6 +211,7 @@ func poolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
|
||||
func poolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -89,12 +89,14 @@ func timeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentTimeNodeName).(string)
|
||||
|
||||
nodeTime, err := api.Node(nodeName).GetTime(ctx)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -125,6 +127,7 @@ func timeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
|
||||
func timeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
api, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -164,6 +164,7 @@ func User() *schema.Resource {
|
||||
|
||||
func userCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -172,6 +173,7 @@ func userCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||
enabled := types.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
||||
|
||||
expirationDate, err := time.Parse(
|
||||
time.RFC3339,
|
||||
d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string),
|
||||
@ -242,12 +244,14 @@ func userCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
|
||||
func userRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
userID := d.Id()
|
||||
|
||||
user, err := client.Access().GetUser(ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, api.ErrResourceDoesNotExist) {
|
||||
@ -359,6 +363,7 @@ func userRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
|
||||
func userUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -367,6 +372,7 @@ func userUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||
enabled := types.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
||||
|
||||
expirationDate, err := time.Parse(
|
||||
time.RFC3339,
|
||||
d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string),
|
||||
@ -399,6 +405,7 @@ func userUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
}
|
||||
|
||||
userID := d.Id()
|
||||
|
||||
err = client.Access().UpdateUser(ctx, userID, body)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -406,6 +413,7 @@ func userUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
|
||||
if d.HasChange(mkResourceVirtualEnvironmentUserPassword) {
|
||||
password := d.Get(mkResourceVirtualEnvironmentUserPassword).(string)
|
||||
|
||||
err = client.Access().ChangeUserPassword(ctx, userID, password)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@ -464,6 +472,7 @@ func userUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag
|
||||
|
||||
func userDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
config := m.(proxmoxtf.ProviderConfiguration)
|
||||
|
||||
client, err := config.GetClient()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
@ -78,6 +78,7 @@ func FileMode() schema.SchemaValidateDiagFunc {
|
||||
if !ok {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
`expected string in octal format (e.g. "0o700" or "0700"") for %q, but got %v of type %T`, k, v, i))
|
||||
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
|
@ -2693,8 +2693,8 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
}
|
||||
|
||||
vmID = vmIDNew
|
||||
e = d.Set(mkVMID, vmID)
|
||||
|
||||
e = d.Set(mkVMID, vmID)
|
||||
if e != nil {
|
||||
return diag.FromErr(e)
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ func TestCloseOrLogError(t *testing.T) {
|
||||
func() {
|
||||
defer f(c)
|
||||
defer f(b)
|
||||
|
||||
assert.False(t, c.isClosed)
|
||||
}()
|
||||
|
||||
|
@ -44,8 +44,8 @@ func compareWithPrefix(a, b string) int {
|
||||
bRest := strings.TrimPrefix(b, prefix)
|
||||
|
||||
aNum, aErr := strconv.Atoi(aRest)
|
||||
bNum, bErr := strconv.Atoi(bRest)
|
||||
|
||||
bNum, bErr := strconv.Atoi(bRest)
|
||||
if aErr == nil && bErr == nil {
|
||||
if aNum != bNum {
|
||||
if aNum < bNum {
|
||||
|
Loading…
Reference in New Issue
Block a user