fix: fix lintings
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / CI (pull_request) Failing after 16m49s
CI Workflow / Code coverage report (pull_request) Has been skipped
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 18m3s

This commit is contained in:
Marcel S. Henselin 2026-02-13 13:02:58 +01:00
parent 843fc46f54
commit 944b872db7
84 changed files with 264 additions and 146 deletions

View file

@ -9,6 +9,7 @@ import (
"time"
"github.com/hashicorp/terraform-plugin-log/tflog"
postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
@ -106,7 +107,7 @@ func CreateInstanceWaitHandler(
),
)
if extendedTimeout < 3 {
maxWait = maxWait + time.Minute*5
maxWait += time.Minute * 5
extendedTimeout = extendedTimeout + 1
if *s.Network.AccessScope == "SNA" {
ready := true
@ -162,6 +163,7 @@ func CreateInstanceWaitHandler(
if !ok {
return false, nil, err
}
// TODO: refactor and cooperate with api guys to mitigate
if oapiErr.StatusCode < 500 {
return true, instanceGetResponse, fmt.Errorf(
"users request after instance creation returned %d status code",
@ -234,10 +236,16 @@ func GetUserByIdWaitHandler(
if !ok {
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
}
if oapiErr.StatusCode != http.StatusNotFound {
switch oapiErr.StatusCode {
case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable:
case http.StatusNotFound:
tflog.Warn(ctx, "api responded with status", map[string]interface{}{
"status": oapiErr.StatusCode,
})
return false, nil, nil
default:
return false, nil, err
}
return false, nil, nil
}
return true, s, nil
},
@ -262,10 +270,16 @@ func GetDatabaseByIdWaitHandler(
if !ok {
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
}
if oapiErr.StatusCode != http.StatusNotFound {
switch oapiErr.StatusCode {
case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable:
case http.StatusNotFound:
tflog.Warn(ctx, "api responded with status", map[string]interface{}{
"status": oapiErr.StatusCode,
})
return false, nil, nil
default:
return false, nil, err
}
return false, nil, nil
}
return true, s, nil
},

View file

@ -10,6 +10,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
)

View file

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/wait"
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
)
@ -42,6 +43,7 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
if err != nil {
// TODO: catch 502, 503 and 504
return false, nil, err
}
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {

View file

@ -10,6 +10,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
)

View file

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/wait"
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
)

View file

@ -8,6 +8,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
)
@ -22,37 +23,37 @@ type apiClientInstanceMocked struct {
type ListUsersRequestRequest struct{}
func (l ListUsersRequestRequest) Page(page int64) sqlserverflex.ApiListUsersRequestRequest {
func (l ListUsersRequestRequest) Page(_ int64) sqlserverflex.ApiListUsersRequestRequest {
return l
}
func (l ListUsersRequestRequest) Size(size int64) sqlserverflex.ApiListUsersRequestRequest {
func (l ListUsersRequestRequest) Size(_ int64) sqlserverflex.ApiListUsersRequestRequest {
return l
}
func (l ListUsersRequestRequest) Sort(sort sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest {
func (l ListUsersRequestRequest) Sort(_ sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest {
return l
}
func (l ListUsersRequestRequest) Execute() (*sqlserverflex.ListUserResponse, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}
func (a *apiClientInstanceMocked) ListUsersRequest(
ctx context.Context,
projectId string,
region string,
instanceId string,
_ context.Context,
_ string,
_ string,
_ string,
) sqlserverflex.ApiListUsersRequestRequest {
return ListUsersRequestRequest{}
}
func (a *apiClientInstanceMocked) ListRolesRequestExecute(
ctx context.Context,
projectId string,
region string,
instanceId string,
_ context.Context,
_ string,
_ string,
_ string,
) (*sqlserverflex.ListRolesResponse, error) {
return &sqlserverflex.ListRolesResponse{
Roles: &[]string{},
@ -60,10 +61,10 @@ func (a *apiClientInstanceMocked) ListRolesRequestExecute(
}
func (a *apiClientInstanceMocked) ListUsersRequestExecute(
ctx context.Context,
projectId string,
region string,
instanceId string,
_ context.Context,
_ string,
_ string,
_ string,
) (*sqlserverflex.ListUserResponse, error) {
return &sqlserverflex.ListUserResponse{
Pagination: nil,
@ -73,20 +74,20 @@ func (a *apiClientInstanceMocked) ListUsersRequestExecute(
func (a *apiClientInstanceMocked) GetDatabaseRequestExecute(
_ context.Context,
projectId string,
region string,
instanceId string,
databaseName string,
_ string,
_ string,
_ string,
_ string,
) (*sqlserverflex.GetDatabaseResponse, error) {
return nil, nil
}
func (a *apiClientInstanceMocked) GetUserRequestExecute(
ctx context.Context,
projectId string,
region string,
instanceId string,
userId int64,
_ context.Context,
_ string,
_ string,
_ string,
_ int64,
) (*sqlserverflex.GetUserResponse, error) {
return nil, nil
}
@ -114,7 +115,7 @@ func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
}, nil
}
func TestCreateInstanceWaitHandler(t *testing.T) {
//t.Skip("skipping - needs refactoring")
// t.Skip("skipping - needs refactoring")
tests := []struct {
desc string
instanceGetFails bool