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

revert import profile mapping #2053

Merged
merged 1 commit into from
Aug 1, 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
1 change: 0 additions & 1 deletion examples/resources/okta_profile_mapping/import.sh

This file was deleted.

12 changes: 3 additions & 9 deletions okta/resource_okta_profile_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func resourceProfileMapping() *schema.Resource {
Default: false,
},
},
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
}
}

Expand Down Expand Up @@ -111,8 +108,7 @@ func resourceProfileMappingCreate(ctx context.Context, d *schema.ResourceData, m
}
d.SetId(mapping.Id)
newMapping := buildMapping(d)
deleteWhenAbsent, ok := d.GetOk("delete_when_absent")
if ok && deleteWhenAbsent.(bool) {
if d.Get("delete_when_absent").(bool) {
newMapping.Properties = mergeProperties(newMapping.Properties, getDeleteProperties(d, mapping.Properties))
}
_, _, err = getOktaClientFromMetadata(m).ProfileMapping.UpdateProfileMapping(ctx, mapping.Id, newMapping)
Expand Down Expand Up @@ -141,8 +137,7 @@ func resourceProfileMappingRead(ctx context.Context, d *schema.ResourceData, m i
_ = d.Set("target_type", mapping.Target.Type)
_ = d.Set("target_id", mapping.Target.Id)
_ = d.Set("target_name", mapping.Target.Name)
deleteWhenAbsent, ok := d.GetOk("delete_when_absent")
if ok && !deleteWhenAbsent.(bool) {
if d.Get("delete_when_absent").(bool) {
current := buildMappingProperties(d.Get("mappings").(*schema.Set))
for k := range mapping.Properties {
if _, ok := current[k]; !ok {
Expand All @@ -165,8 +160,7 @@ func resourceProfileMappingUpdate(ctx context.Context, d *schema.ResourceData, m
return diag.Errorf("no profile mappings found for source ID '%s' and target ID '%s'", sourceID, targetID)
}
newMapping := buildMapping(d)
deleteWhenAbsent, ok := d.GetOk("delete_when_absent")
if ok && deleteWhenAbsent.(bool) {
if d.Get("delete_when_absent").(bool) {
newMapping.Properties = mergeProperties(newMapping.Properties, getDeleteProperties(d, mapping.Properties))
}
_, _, err = getOktaClientFromMetadata(m).ProfileMapping.UpdateProfileMapping(ctx, mapping.Id, newMapping)
Expand Down