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
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:
parent
ab9ff41b24
commit
c8ea125bac
45 changed files with 1266 additions and 139 deletions
|
|
@ -65,7 +65,7 @@ func getDatabase(
|
|||
}
|
||||
|
||||
// If the API returns no databases, we have reached the end of the list.
|
||||
if res.Databases == nil || len(res.Databases) == 0 {
|
||||
if len(res.Databases) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
postgresflexalpha "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||
|
||||
datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -397,14 +397,14 @@ func (r *databaseResource) Update(
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "error updating database", "databaseID out of bounds for int32")
|
||||
return
|
||||
}
|
||||
databaseId32 := int32(databaseId)
|
||||
databaseID32 := int32(databaseId) //nolint:gosec // TODO
|
||||
// Update existing database
|
||||
err := r.client.DefaultAPI.UpdateDatabasePartiallyRequest(
|
||||
ctx,
|
||||
projectId,
|
||||
region,
|
||||
instanceId,
|
||||
databaseId32,
|
||||
databaseID32,
|
||||
).UpdateDatabasePartiallyRequestPayload(payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "error updating database", err.Error())
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
package postgresFlexAlphaFlavor
|
||||
|
||||
//
|
||||
//import (
|
||||
// import (
|
||||
// "context"
|
||||
// "testing"
|
||||
//
|
||||
// postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||
//)
|
||||
//
|
||||
//type mockRequest struct {
|
||||
// type mockRequest struct {
|
||||
// executeFunc func() (*postgresflex.GetFlavorsResponse, error)
|
||||
//}
|
||||
//
|
||||
//func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||
//func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||
//func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest {
|
||||
// func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||
// func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||
// func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest {
|
||||
// return m
|
||||
//}
|
||||
//func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) {
|
||||
// func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) {
|
||||
// return m.executeFunc()
|
||||
//}
|
||||
//
|
||||
//type mockFlavorsClient struct {
|
||||
// type mockFlavorsClient struct {
|
||||
// executeRequest func() postgresflex.ApiGetFlavorsRequestRequest
|
||||
//}
|
||||
//
|
||||
//func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest {
|
||||
// func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest {
|
||||
// return m.executeRequest()
|
||||
//}
|
||||
//
|
||||
//var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) {
|
||||
// var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) {
|
||||
// if page == 1 {
|
||||
// return &postgresflex.GetFlavorsResponse{
|
||||
// Flavors: []postgresflex.ListFlavors{
|
||||
|
|
@ -51,7 +51,7 @@ package postgresFlexAlphaFlavor
|
|||
// }, nil
|
||||
//}
|
||||
//
|
||||
//func TestGetFlavorsByFilter(t *testing.T) {
|
||||
// func TestGetFlavorsByFilter(t *testing.T) {
|
||||
// tests := []struct {
|
||||
// description string
|
||||
// projectId string
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ func TestAccInstance(t *testing.T) {
|
|||
{
|
||||
//PreConfig: func() {
|
||||
// //
|
||||
//},
|
||||
// },
|
||||
Config: testutils.StringFromTemplateMust(
|
||||
"testdata/instance_template.gompl",
|
||||
exData,
|
||||
|
|
|
|||
|
|
@ -23,11 +23,10 @@ func mapDataSourceFields(userResp *v3alpha1api.GetUserResponse, model *dataSourc
|
|||
user := userResp
|
||||
|
||||
var userID int64
|
||||
if model.UserId.ValueInt64() != 0 {
|
||||
userID = model.UserId.ValueInt64()
|
||||
} else {
|
||||
if model.UserId.ValueInt64() == 0 {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
userID = model.UserId.ValueInt64()
|
||||
|
||||
model.TerraformID = utils.BuildInternalTerraformId(
|
||||
model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userID, 10),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue