feat(telemetrylink): v1api and waiters#7520
Conversation
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
This PR was closed automatically because it has been stalled for 7 days with no activity. Feel free to re-open it at any time. |
| const ( | ||
| // Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing | ||
| //go:fix inline | ||
| TELEMETRYLINK_ACTIVE = telemetrylink.TELEMETRYLINKRESPONSESTATUS_ACTIVE | ||
| ) |
There was a problem hiding this comment.
Can be removed, because for the v1api package the const was never released :)
| const ( | |
| // Deprecated: symbol is not used anymore, use the packages enum instead, will be removed 2026-12, use `go fix` for automatic fixing | |
| //go:fix inline | |
| TELEMETRYLINK_ACTIVE = telemetrylink.TELEMETRYLINKRESPONSESTATUS_ACTIVE | |
| ) |
| // CreateOrUpdateOrganizationTelemetryLinkWaitHandler will wait for organization TelemetryLink creation or update | ||
| func CreateOrUpdateOrganizationTelemetryLinkWaitHandler(ctx context.Context, a telemetrylink.DefaultAPI, organizationId, region string) *wait.AsyncActionHandler[telemetrylink.TelemetryLinkResponse] { | ||
| waitConfig := wait.WaiterHelper[telemetrylink.TelemetryLinkResponse, telemetrylink.TelemetryLinkResponseStatus]{ | ||
| FetchInstance: a.GetOrganizationTelemetryLink(ctx, organizationId, region).Execute, | ||
| GetState: func(d *telemetrylink.TelemetryLinkResponse) (telemetrylink.TelemetryLinkResponseStatus, error) { | ||
| if d == nil { | ||
| return "", errors.New("empty response") | ||
| } | ||
| return d.Status, nil | ||
| }, | ||
| ActiveState: []telemetrylink.TelemetryLinkResponseStatus{telemetrylink.TELEMETRYLINKRESPONSESTATUS_ACTIVE}, | ||
| } | ||
|
|
||
| handler := wait.New(waitConfig.Wait()) | ||
| handler.SetTimeout(10 * time.Minute) | ||
| return handler | ||
| } |
There was a problem hiding this comment.
Can you separate the WaitHandler to one for creation and one for update? You can also keep one private function, which you call in these dedicated Waithandler. But we want to be prepared in case the API will be separated in the future.
So it should be similar like here: 6c8df70
I also recognize, that only the ActiveState is defined, but ErrorState is missing. So in case an operation fails, it would always continue to wait until it runs into a timeout. Please extend it
ErrorState: []telemetrylink.TelemetryLinkResponseStatus{telemetrylink.TELEMETRYLINKRESPONSESTATUS_FAILED},There was a problem hiding this comment.
This comment applies also to the other waithandlers. I saw that in most cases there is already a dedicated waithandler for PartialUpdate, so it should be fine if you just change the prefix CreateOrUpdate to Create and share the logic between Create and PartialUpdate, because they behave the same.
| }, | ||
| DeleteHttpErrorStatusCodes: []int{http.StatusNotFound}, |
There was a problem hiding this comment.
here also the ErrorStates are missing, but the GetState function reads them. Please extend here the errorStates
There was a problem hiding this comment.
applies also to the other Delete WaitHandler
Description
v1api and waiters
Checklist
make fmtexamples/directory)make test(will be checked by CI)make lint(will be checked by CI)