Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No jira: auth data source minor refactor #1270

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ func dataSourceAuthDivisionRead(ctx context.Context, d *schema.ResourceData, m i
// Query division by name. Retry in case search has not yet indexed the division.
return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError {
divisionId, resp, retryable, getErr := proxy.getAuthDivisionIdByName(ctx, name)
if getErr != nil && !retryable {
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error requesting division %s | error: %s", name, getErr), resp))
}
if retryable {
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error requesting division %s | error: %s", name, getErr), resp))
if getErr != nil {
errorDetails := util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error requesting division %s | error: %s", name, getErr), resp)
if !retryable {
return retry.NonRetryableError(errorDetails)
}
return retry.RetryableError(errorDetails)
}

d.SetId(divisionId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ func getAuthDivisionByIdFn(ctx context.Context, p *authDivisionProxy, id string,
}

func getAuthDivisionIdByNameFn(ctx context.Context, p *authDivisionProxy, name string) (string, *platformclientv2.APIResponse, bool, error) {
notFoundError := fmt.Errorf("unable to find auth division with name %s", name)

authzDivisions, resp, err := getAllAuthDivisionFn(ctx, p, name)
if err != nil {
return "", resp, false, err
}

if authzDivisions == nil || len(*authzDivisions) == 0 {
return "", resp, true, err
return "", resp, true, notFoundError
carnellj-genesys marked this conversation as resolved.
Show resolved Hide resolved
}

for _, authzDivision := range *authzDivisions {
Expand All @@ -147,7 +149,7 @@ func getAuthDivisionIdByNameFn(ctx context.Context, p *authDivisionProxy, name s
}
}

return "", resp, true, fmt.Errorf("unable to find auth division with name %s", name)
return "", resp, true, notFoundError
}

func updateAuthDivisionFn(ctx context.Context, p *authDivisionProxy, id string, authDivision *platformclientv2.Authzdivision) (*platformclientv2.Authzdivision, *platformclientv2.APIResponse, error) {
Expand Down
Loading