fix: fix linter errors
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 17s
CI Workflow / Prepare GO cache (pull_request) Successful in 2m10s
CI Workflow / CI run build and linting (pull_request) Successful in 7m10s
CI Workflow / Code coverage report (pull_request) Successful in 4s
CI Workflow / CI run tests (pull_request) Failing after 9m13s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 16m53s

This commit is contained in:
Marcel S. Henselin 2026-03-09 14:03:29 +01:00
parent ab9ff41b24
commit c8ea125bac
45 changed files with 1266 additions and 139 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
_ "embed"
"fmt"
"math"
"net/http"
"strings"
@ -294,11 +295,11 @@ func modelToCreateInstancePayload(
AccessScope: (*v3alpha1api.InstanceNetworkAccessScope)(model.Network.AccessScope.ValueStringPointer()),
Acl: netACL,
},
Replicas: v3alpha1api.Replicas(replVal),
RetentionDays: int32(model.RetentionDays.ValueInt64()),
Replicas: v3alpha1api.Replicas(replVal), //nolint:gosec // TODO
RetentionDays: int32(model.RetentionDays.ValueInt64()), //nolint:gosec // TODO
Storage: v3alpha1api.StorageCreate{
PerformanceClass: model.Storage.PerformanceClass.ValueString(),
Size: int32(model.Storage.Size.ValueInt64()),
Size: int32(model.Storage.Size.ValueInt64()), //nolint:gosec // TODO
},
Version: model.Version.ValueString(),
}
@ -425,32 +426,46 @@ func (r *instanceResource) Update(
return
}
projectId := identityData.ProjectID.ValueString()
instanceId := identityData.InstanceID.ValueString()
projectID := identityData.ProjectID.ValueString()
instanceID := identityData.InstanceID.ValueString()
region := model.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
ctx = tflog.SetField(ctx, "project_id", projectID)
ctx = tflog.SetField(ctx, "instance_id", instanceID)
ctx = tflog.SetField(ctx, "region", region)
var netAcl []string
diag := model.Network.Acl.ElementsAs(ctx, &netAcl, false)
var netACL []string
diag := model.Network.Acl.ElementsAs(ctx, &netACL, false)
resp.Diagnostics.Append(diags...)
if diag.HasError() {
return
}
replInt32 := model.Replicas.ValueInt64()
if model.Replicas.ValueInt64() > math.MaxInt32 {
core.LogAndAddError(ctx, &resp.Diagnostics, "UPDATE", "replicas value too large for int32")
return
}
if model.RetentionDays.ValueInt64() > math.MaxInt32 {
core.LogAndAddError(ctx, &resp.Diagnostics, "UPDATE", "retention_days value too large for int32")
return
}
if model.Storage.Size.ValueInt64() > math.MaxInt32 {
core.LogAndAddError(ctx, &resp.Diagnostics, "UPDATE", "storage.size value too large for int32")
return
}
payload := v3alpha1api.UpdateInstanceRequestPayload{
BackupSchedule: model.BackupSchedule.ValueString(),
FlavorId: model.FlavorId.ValueString(),
Name: model.Name.ValueString(),
Network: v3alpha1api.InstanceNetworkUpdate{
Acl: netAcl,
Acl: netACL,
},
Replicas: v3alpha1api.Replicas(replInt32),
RetentionDays: int32(model.RetentionDays.ValueInt64()),
Replicas: v3alpha1api.Replicas(model.Replicas.ValueInt64()), //nolint:gosec // checked above
RetentionDays: int32(model.RetentionDays.ValueInt64()), //nolint:gosec // checked above
Storage: v3alpha1api.StorageUpdate{
Size: coreUtils.Ptr(int32(model.Storage.Size.ValueInt64())),
Size: coreUtils.Ptr(int32(model.Storage.Size.ValueInt64())), //nolint:gosec // checked above
},
Version: model.Version.ValueString(),
}
@ -458,9 +473,9 @@ func (r *instanceResource) Update(
// Update existing instance
err := r.client.DefaultAPI.UpdateInstanceRequest(
ctx,
projectId,
projectID,
region,
instanceId,
instanceID,
).UpdateInstanceRequestPayload(payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
@ -472,9 +487,9 @@ func (r *instanceResource) Update(
waitResp, err := wait.PartialUpdateInstanceWaitHandler(
ctx,
r.client.DefaultAPI,
projectId,
projectID,
region,
instanceId,
instanceID,
).WaitWithContext(ctx)
if err != nil {
core.LogAndAddError(