Skip to content

Commit

Permalink
Merge pull request #15 from netdata/fix/import-space-claim-id
Browse files Browse the repository at this point in the history
fix: empty claim token when importing space
  • Loading branch information
witalisoft authored Mar 26, 2024
2 parents d9d363f + df28377 commit be412fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.1

BUGFIXES:

- empty claim token when importing space

## 0.1.0

Initial version.
Expand Down
13 changes: 13 additions & 0 deletions internal/provider/space_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ func (s *spaceResource) Read(ctx context.Context, req resource.ReadRequest, resp
return
}

if state.ClaimToken.IsNull() {
tflog.Info(ctx, "Creating Claim Token for Space ID: "+spaceInfo.ID)
claimToken, err := s.client.GetSpaceClaimToken(spaceInfo.ID)
if err != nil {
resp.Diagnostics.AddError(
"Error Creating Claim Token",
"Could Not Create Claim Token for Space ID: "+spaceInfo.ID+": err: "+err.Error(),
)
return
}
state.ClaimToken = types.StringValue(*claimToken)
}

state.Name = types.StringValue(spaceInfo.Name)
state.Description = types.StringValue(spaceInfo.Description)
diags = resp.State.Set(ctx, &state)
Expand Down

0 comments on commit be412fb

Please sign in to comment.