From df28377dfbaf9b9d3560c0d12fb59f3a051c5d47 Mon Sep 17 00:00:00 2001 From: Witold Duranek Date: Tue, 26 Mar 2024 11:36:36 +0100 Subject: [PATCH] fix: empty claim token when importing space --- CHANGELOG.md | 6 ++++++ internal/provider/space_resource.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d16f1..665ee79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.1.1 + +BUGFIXES: + +- empty claim token when importing space + ## 0.1.0 Initial version. diff --git a/internal/provider/space_resource.go b/internal/provider/space_resource.go index 3c06f47..f6e3cdb 100644 --- a/internal/provider/space_resource.go +++ b/internal/provider/space_resource.go @@ -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)