Skip to content

Commit

Permalink
revert import profile mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Tien Nguyen <[email protected]>
  • Loading branch information
duytiennguyen-okta committed Jul 31, 2024
1 parent de43f1d commit ce943a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
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

0 comments on commit ce943a2

Please sign in to comment.