Skip to content

Commit

Permalink
Change the search attribute id from uuid to <ns>/<sa_name> (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
anekkanti authored Oct 11, 2024
1 parent 6bcadc9 commit 2cc1206
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions internal/provider/namespace_search_attribute_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"strings"

"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down Expand Up @@ -156,13 +155,7 @@ func (r *namespaceSearchAttributeResource) Create(ctx context.Context, req resou
return
}

id, err := uuid.GenerateUUID()
if err != nil {
resp.Diagnostics.AddError("Failed to generate UUID", err.Error())
return
}

plan.ID = types.StringValue(id)
plan.ID = types.StringValue(updatedNs.GetNamespace().GetNamespace() + "/" + plan.Name.ValueString())
plan.NamespaceID = types.StringValue(updatedNs.GetNamespace().GetNamespace())
resp.Diagnostics.Append(plan.updateFromSpec(updatedNs.GetNamespace().GetSpec())...)
if resp.Diagnostics.HasError() {
Expand Down Expand Up @@ -286,14 +279,8 @@ func (r *namespaceSearchAttributeResource) ImportState(ctx context.Context, req
}

nsID, saName := components[0], components[1]
id, err := uuid.GenerateUUID()
if err != nil {
resp.Diagnostics.AddError("Failed to generate UUID", err.Error())
return
}

var state namespaceSearchAttributeModel
state.ID = types.StringValue(id)
state.ID = types.StringValue(req.ID)
state.NamespaceID = types.StringValue(nsID)
state.Name = types.StringValue(saName)
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
Expand Down

0 comments on commit 2cc1206

Please sign in to comment.