fix: remove identity from sqlserverbeta and postresflexalpha
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Failing after 4m51s
CI Workflow / Prepare GO cache (pull_request) Successful in 6m12s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled

This commit is contained in:
Marcel S. Henselin 2026-03-17 14:31:25 +01:00
parent 042e8115a6
commit 746f7cdfbd
13 changed files with 1438 additions and 259 deletions

View file

@ -30,35 +30,35 @@ const (
type APIClientInterface interface {
GetInstanceRequest(
ctx context.Context,
projectId, region, instanceId string,
projectID, region, instanceID string,
) sqlserverflex.ApiGetInstanceRequestRequest
GetDatabaseRequest(
ctx context.Context,
projectId string,
projectID string,
region string,
instanceId string,
instanceID string,
databaseName string,
) sqlserverflex.ApiGetDatabaseRequestRequest
GetUserRequest(
ctx context.Context,
projectId string,
projectID string,
region string,
instanceId string,
userId int64,
instanceID string,
userID int64,
) sqlserverflex.ApiGetUserRequestRequest
ListRolesRequest(
ctx context.Context,
projectId string,
projectID string,
region string,
instanceId string,
instanceID string,
) sqlserverflex.ApiListRolesRequestRequest
ListUsersRequest(
ctx context.Context,
projectId string,
projectID string,
region string,
instanceId string,
instanceID string,
) sqlserverflex.ApiListUsersRequestRequest
}
@ -66,10 +66,10 @@ type APIClientInterface interface {
type APIClientUserInterface interface {
DeleteUserRequestExecute(
ctx context.Context,
projectId string,
projectID string,
region string,
instanceId string,
userId int64,
instanceID string,
userID int64,
) error
}
@ -77,11 +77,11 @@ type APIClientUserInterface interface {
func CreateInstanceWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region string,
projectID, instanceID, region string,
) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
handler := wait.New(
func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
@ -95,7 +95,7 @@ func CreateInstanceWaitHandler(
return false, nil, fmt.Errorf("api error: %w", err)
}
}
if s == nil || s.Id != instanceId {
if s == nil || s.Id != instanceID {
return false, nil, nil
}
switch strings.ToLower(string(s.Status)) {
@ -113,7 +113,7 @@ func CreateInstanceWaitHandler(
tflog.Info(ctx, "trying to get roles")
time.Sleep(10 * time.Second)
_, rolesErr := a.ListRolesRequest(ctx, projectId, region, instanceId).Execute()
_, rolesErr := a.ListRolesRequest(ctx, projectID, region, instanceID).Execute()
if rolesErr != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(rolesErr, &oapiErr)
@ -137,7 +137,7 @@ func CreateInstanceWaitHandler(
tflog.Info(ctx, "trying to get users")
time.Sleep(10 * time.Second)
_, usersErr := a.ListUsersRequest(ctx, projectId, region, instanceId).Execute()
_, usersErr := a.ListUsersRequest(ctx, projectID, region, instanceID).Execute()
if usersErr != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(usersErr, &oapiErr)
@ -162,13 +162,13 @@ func CreateInstanceWaitHandler(
case strings.ToLower(InstanceStateUnknown):
return true, nil, fmt.Errorf(
"create failed for instance %s with status %s",
instanceId,
instanceID,
InstanceStateUnknown,
)
case strings.ToLower(InstanceStateFailed):
return true, nil, fmt.Errorf(
"create failed for instance %s with status %s",
instanceId,
instanceID,
InstanceStateFailed,
)
case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
@ -182,7 +182,7 @@ func CreateInstanceWaitHandler(
default:
tflog.Info(
ctx, "Wait (create) received unknown status", map[string]interface{}{
"instanceId": instanceId,
"instanceId": instanceID,
"status": s.Status,
},
)
@ -197,22 +197,22 @@ func CreateInstanceWaitHandler(
func UpdateInstanceWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region string,
projectID, instanceID, region string,
) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
handler := wait.New(
func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
if err != nil {
return false, nil, err
}
if s == nil || s.Id != instanceId {
if s == nil || s.Id != instanceID {
return false, nil, nil
}
switch strings.ToLower(string(s.Status)) {
case strings.ToLower(InstanceStateSuccess):
return true, s, nil
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
return true, s, fmt.Errorf("update failed for instance with id %s", instanceID)
case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing):
tflog.Info(
ctx, "request is being handled", map[string]interface{}{
@ -223,7 +223,7 @@ func UpdateInstanceWaitHandler(
default:
tflog.Info(
ctx, "Wait (update) received unknown status", map[string]interface{}{
"instanceId": instanceId,
"instanceId": instanceID,
"status": s.Status,
},
)
@ -238,11 +238,11 @@ func UpdateInstanceWaitHandler(
func DeleteInstanceWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region string,
projectID, instanceID, region string,
) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
handler := wait.New(
func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequest(ctx, projectId, region, instanceId).Execute()
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
if err == nil {
return false, s, nil
}
@ -265,11 +265,11 @@ func DeleteInstanceWaitHandler(
func CreateDatabaseWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region, databaseName string,
projectID, instanceID, region, databaseName string,
) *wait.AsyncActionHandler[sqlserverflex.GetDatabaseResponse] {
handler := wait.New(
func() (waitFinished bool, response *sqlserverflex.GetDatabaseResponse, err error) {
s, err := a.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
s, err := a.GetDatabaseRequest(ctx, projectID, region, instanceID, databaseName).Execute()
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
@ -297,12 +297,12 @@ func CreateDatabaseWaitHandler(
func CreateUserWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region string,
userId int64,
projectID, instanceID, region string,
userID int64,
) *wait.AsyncActionHandler[sqlserverflex.GetUserResponse] {
handler := wait.New(
func() (waitFinished bool, response *sqlserverflex.GetUserResponse, err error) {
s, err := a.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
s, err := a.GetUserRequest(ctx, projectID, region, instanceID, userID).Execute()
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
@ -324,7 +324,7 @@ func CreateUserWaitHandler(
func WaitForUserWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, instanceId, region, userName string,
projectID, instanceID, region, userName string,
) *wait.AsyncActionHandler[sqlserverflex.ListUserResponse] {
startTime := time.Now()
timeOut := 2 * time.Minute
@ -334,7 +334,7 @@ func WaitForUserWaitHandler(
if time.Since(startTime) > timeOut {
return false, nil, errors.New("ran into timeout")
}
s, err := a.ListUsersRequest(ctx, projectId, region, instanceId).Size(100).Execute()
s, err := a.ListUsersRequest(ctx, projectID, region, instanceID).Size(100).Execute()
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
@ -376,12 +376,12 @@ func WaitForUserWaitHandler(
func DeleteUserWaitHandler(
ctx context.Context,
a APIClientInterface,
projectId, region, instanceId string,
userId int64,
projectID, region, instanceID string,
userID int64,
) *wait.AsyncActionHandler[struct{}] {
handler := wait.New(
func() (waitFinished bool, response *struct{}, err error) {
_, err = a.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
_, err = a.GetUserRequest(ctx, projectID, region, instanceID, userID).Execute()
if err == nil {
return false, nil, nil
}