Skip to content

Commit

Permalink
fix import okta_group_memberships
Browse files Browse the repository at this point in the history
  • Loading branch information
c4po committed Feb 12, 2024
1 parent edb27b5 commit 8acaaec
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions okta/resource_okta_group_memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package okta

import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/cenkalti/backoff/v4"
Expand All @@ -18,8 +20,22 @@ func resourceGroupMemberships() *schema.Resource {
ReadContext: resourceGroupMembershipsRead,
UpdateContext: resourceGroupMembershipsUpdate,
DeleteContext: resourceGroupMembershipsDelete,
Importer: createNestedResourceImporter([]string{"id", "track_all_users"}),
Description: "Resource to manage a set of group memberships for a specific group.",
Importer: &schema.ResourceImporter{
StateContext: func(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
importID := strings.Split(d.Id(), "/")
if len(importID) > 2 {
return nil, errors.New("invalid format used for import ID, format must be 'group_id' or 'group_id/true'")
}
if len(importID) == 2 {
d.Set("track_all_users", importID[1] == "true")
}
d.SetId(importID[0])
d.Set("group_id", importID[0])
return []*schema.ResourceData{d}, nil
},
},

Description: "Resource to manage a set of group memberships for a specific group.",
Schema: map[string]*schema.Schema{
"group_id": {
Type: schema.TypeString,
Expand Down

0 comments on commit 8acaaec

Please sign in to comment.