chore(terraform): use a util func to build internal terraform id (#869)
This commit is contained in:
parent
801ef6033d
commit
b313ef6a39
72 changed files with 205 additions and 538 deletions
|
|
@ -7,6 +7,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
|
||||
|
||||
serviceaccountUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/serviceaccount/utils"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||
|
|
@ -301,8 +303,7 @@ func mapFields(resp *serviceaccount.ServiceAccount, model *Model) error {
|
|||
}
|
||||
|
||||
// Build the ID by combining the project ID and email and assign the model's fields.
|
||||
idParts := []string{model.ProjectId.ValueString(), *resp.Email}
|
||||
model.Id = types.StringValue(strings.Join(idParts, core.Separator))
|
||||
model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), *resp.Email)
|
||||
model.Email = types.StringPointerValue(resp.Email)
|
||||
model.ProjectId = types.StringPointerValue(resp.ProjectId)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
serviceaccountUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/serviceaccount/utils"
|
||||
|
|
@ -325,8 +324,7 @@ func mapCreateResponse(resp *serviceaccount.CreateServiceAccountKeyResponse, mod
|
|||
return fmt.Errorf("service account key id not present")
|
||||
}
|
||||
|
||||
idParts := []string{model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id}
|
||||
model.Id = types.StringValue(strings.Join(idParts, core.Separator))
|
||||
model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id)
|
||||
model.KeyId = types.StringPointerValue(resp.Id)
|
||||
|
||||
jsonData, err := json.Marshal(resp)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
|
||||
|
||||
serviceaccountUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/serviceaccount/utils"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
|
||||
|
|
@ -344,8 +345,7 @@ func mapCreateResponse(resp *serviceaccount.AccessToken, model *Model) error {
|
|||
validUntil = types.StringValue(validUntilValue.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
idParts := []string{model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id}
|
||||
model.Id = types.StringValue(strings.Join(idParts, core.Separator))
|
||||
model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id)
|
||||
model.AccessTokenId = types.StringPointerValue(resp.Id)
|
||||
model.Token = types.StringPointerValue(resp.Token)
|
||||
model.Active = types.BoolPointerValue(resp.Active)
|
||||
|
|
@ -379,8 +379,7 @@ func mapListResponse(resp *serviceaccount.AccessTokenMetadata, model *Model) err
|
|||
validUntil = types.StringValue(validUntilValue.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
idParts := []string{model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id}
|
||||
model.Id = types.StringValue(strings.Join(idParts, core.Separator))
|
||||
model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), model.ServiceAccountEmail.ValueString(), *resp.Id)
|
||||
model.AccessTokenId = types.StringPointerValue(resp.Id)
|
||||
model.CreatedAt = createdAt
|
||||
model.ValidUntil = validUntil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue