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

handle empty/missing okta_group_owners #2101

Merged
merged 2 commits into from
Oct 18, 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
2 changes: 1 addition & 1 deletion okta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

const (
OktaTerraformProviderVersion = "4.11.0"
OktaTerraformProviderVersion = "4.11.1"
OktaTerraformProviderUserAgent = "okta-terraform/" + OktaTerraformProviderVersion
)

Expand Down
8 changes: 7 additions & 1 deletion okta/resource_okta_group_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (r *groupOwnerResource) Read(ctx context.Context, req resource.ReadRequest,
var err error

listGroupOwners, _, err := r.Config.oktaSDKClientV5.GroupOwnerAPI.ListGroupOwners(ctx, state.GroupID.ValueString()).Execute()

if err != nil {
resp.Diagnostics.AddError(
"Error retrieving list group owners",
Expand All @@ -144,9 +143,16 @@ func (r *groupOwnerResource) Read(ctx context.Context, req resource.ReadRequest,
for _, groupOwner := range listGroupOwners {
if groupOwner.GetId() == state.ID.ValueString() {
grpOwner = &groupOwner
break
}
}

if grpOwner == nil {
// The resource no longer exists; remove it from state
resp.State.RemoveResource(ctx)
return
}

resp.Diagnostics.Append(mapGroupOwnerToState(grpOwner, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down