Generator: Update SDK /services/postgresflex#8450
Conversation
… bump version relates to STACKITSDK-468
| const ( | ||
| InstanceStateEmpty = "" | ||
| ) |
There was a problem hiding this comment.
| const ( | |
| InstanceStateEmpty = "" | |
| ) |
shouldn't be needed anymore
| switch s.State { | ||
| default: | ||
| return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, s.State) | ||
| case InstanceStateEmpty: | ||
| return false, nil, nil | ||
| case postgresflex.STATE_PROGRESSING: | ||
| return false, nil, nil | ||
| case postgresflex.STATE_READY: | ||
| instanceCreated = true | ||
| instanceGetResponse = s | ||
| case postgresflex.STATE_FAILURE: | ||
| return true, s, fmt.Errorf("create failed for instance with id %s", instanceId) | ||
| } |
There was a problem hiding this comment.
I would suggest to write this a bit different.
It should check only for ready state and error state.
In case of ready it should behave like now. In case of an error state it should fail with an error, like in the FAILURE state.
In the default case, it should continue to wait and not thrown an error. This makes it more robust in case the API provides new states and is similar to the behavior of our WaiterHelper function
| if err == nil { | ||
| return true, instanceGetResponse, nil | ||
| } | ||
| oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped |
There was a problem hiding this comment.
nitpick
| oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped | |
| var oapiErr *oapierror.GenericOpenAPIError | |
| ok := errors.As(err, &oapiErr) |
| if oapiErr.StatusCode < 500 { | ||
| return true, instanceGetResponse, fmt.Errorf("users request after instance creation returned %d status code", oapiErr.StatusCode) | ||
| } |
There was a problem hiding this comment.
should be probably changed to an explicit 423 check to continue to wait. In every other error code, we can probably assume that something went completely wrong.
| if oapiErr.StatusCode < 500 { | |
| return true, instanceGetResponse, fmt.Errorf("users request after instance creation returned %d status code", oapiErr.StatusCode) | |
| } | |
| if oapiErr.StatusCode != 423 { | |
| return true, instanceGetResponse, fmt.Errorf("users request after instance creation returned %d status code", oapiErr.StatusCode) | |
| } |
But need to double check this
| return handler | ||
| } | ||
|
|
||
| // DeleteUserWaitHandler will wait for delete |
There was a problem hiding this comment.
For users there is also a create waiter needed because it's also asynchronus
| os.Exit(1) | ||
| } | ||
|
|
||
| fmt.Printf("Created user \"%s\" associated to instance \"%s\".\n", username, instanceResp.Name) |
There was a problem hiding this comment.
| fmt.Printf("Created user \"%s\" associated to instance \"%s\".\n", username, instanceResp.Name) | |
| fmt.Printf("Created user %q associated to instance %q.\n", username, instanceResp.Name) |
| fmt.Fprintf(os.Stderr, "Error when waiting for PostgreSQL Flex user deletion: %v", err) | ||
| } | ||
|
|
||
| fmt.Printf("Deleted PostgreSQL Flex user \"%s\".\n", instanceId) |
There was a problem hiding this comment.
| fmt.Printf("Deleted PostgreSQL Flex user \"%s\".\n", instanceId) | |
| fmt.Printf("Deleted PostgreSQL Flex user %q.\n", instanceId) |
| fmt.Fprintf(os.Stderr, "Error when waiting for PostgreSQL Flex instance deletion: %v", err) | ||
| } | ||
|
|
||
| fmt.Printf("Deleted PostgreSQL Flex instance \"%s\".\n", instanceId) |
There was a problem hiding this comment.
| fmt.Printf("Deleted PostgreSQL Flex instance \"%s\".\n", instanceId) | |
| fmt.Printf("Deleted PostgreSQL Flex instance %q.\n", instanceId) |
Relates to STACKITSDK-468
Generated from GitHub run 28926724566
spec comparison: stackitcloud/stackit-api-specifications@9873a8f...72230b8