Feat/alpa postgres user (#14)
* chore: add stackit_postgresflexalpha_user resource * chore: refactor postgresflex user resource to postgresflexalpha * chore: refactor wait handlers and update API client interfaces for postgresflexalpha * chore: add stackit_postgresflexalpha_user data source example * fix: refactor sqlserverflexalpha user resource and enhance schema with status and default_database --------- Co-authored-by: Andre Harms <andre.harms@stackit.cloud>
This commit is contained in:
parent
f0414ab3b9
commit
6aac685ed4
3 changed files with 30 additions and 22 deletions
|
|
@ -144,15 +144,16 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.desc, func(t *testing.T) {
|
t.Run(
|
||||||
instanceId := "foo-bar"
|
tt.desc, func(t *testing.T) {
|
||||||
|
instanceId := "foo-bar"
|
||||||
|
|
||||||
apiClient := &apiClientInstanceMocked{
|
apiClient := &apiClientInstanceMocked{
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
instanceState: tt.instanceState,
|
instanceState: tt.instanceState,
|
||||||
instanceGetFails: tt.instanceGetFails,
|
instanceGetFails: tt.instanceGetFails,
|
||||||
usersGetErrorStatus: tt.usersGetErrorStatus,
|
usersGetErrorStatus: tt.usersGetErrorStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
var wantRes *postgresflex.GetInstanceResponse
|
var wantRes *postgresflex.GetInstanceResponse
|
||||||
if tt.wantResp {
|
if tt.wantResp {
|
||||||
|
|
@ -220,14 +221,15 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.desc, func(t *testing.T) {
|
t.Run(
|
||||||
instanceId := "foo-bar"
|
tt.desc, func(t *testing.T) {
|
||||||
|
instanceId := "foo-bar"
|
||||||
|
|
||||||
apiClient := &apiClientInstanceMocked{
|
apiClient := &apiClientInstanceMocked{
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
instanceState: tt.instanceState,
|
instanceState: tt.instanceState,
|
||||||
instanceGetFails: tt.instanceGetFails,
|
instanceGetFails: tt.instanceGetFails,
|
||||||
}
|
}
|
||||||
|
|
||||||
var wantRes *postgresflex.GetInstanceResponse
|
var wantRes *postgresflex.GetInstanceResponse
|
||||||
if tt.wantResp {
|
if tt.wantResp {
|
||||||
|
|
@ -376,13 +378,13 @@ func TestDeleteUserWaitHandler(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.desc, func(t *testing.T) {
|
t.Run(tt.desc, func(t *testing.T) {
|
||||||
userId := int64(1001)
|
userId := "foo-bar"
|
||||||
|
|
||||||
apiClient := &apiClientUserMocked{
|
apiClient := &apiClientUserMocked{
|
||||||
getFails: tt.getFails,
|
getFails: tt.getFails,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
isUserDeleted: !tt.deleteFails,
|
isUserDeleted: !tt.deleteFails,
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := DeleteUserWaitHandler(context.Background(), apiClient, "", "", "", userId)
|
handler := DeleteUserWaitHandler(context.Background(), apiClient, "", "", "", userId)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
data "stackit_postgresflexalpha_user" "example" {
|
||||||
|
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||||
|
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
||||||
|
user_id = 1
|
||||||
|
}
|
||||||
|
|
||||||
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
||||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func ConfigureClient(
|
||||||
} else {
|
} else {
|
||||||
apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(providerData.GetRegion()))
|
apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(providerData.GetRegion()))
|
||||||
}
|
}
|
||||||
apiClient, err := sqlserverflexalpha.NewAPIClient(apiClientConfigOptions...)
|
apiClient, err := sqlserverflex.NewAPIClient(apiClientConfigOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
core.LogAndAddError(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue