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
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
||||
|
|
@ -201,14 +200,8 @@ func mapDataSourceFields(credentialResp *objectstorage.AccessKey, model *DataSou
|
|||
model.ExpirationTimestamp = types.StringValue(expirationTimestamp.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
idParts := []string{
|
||||
model.ProjectId.ValueString(),
|
||||
region,
|
||||
model.CredentialsGroupId.ValueString(),
|
||||
credentialId,
|
||||
}
|
||||
model.Id = types.StringValue(
|
||||
strings.Join(idParts, core.Separator),
|
||||
model.Id = utils.BuildInternalTerraformId(
|
||||
model.ProjectId.ValueString(), region, model.CredentialsGroupId.ValueString(), credentialId,
|
||||
)
|
||||
model.CredentialId = types.StringValue(credentialId)
|
||||
model.Name = types.StringPointerValue(credentialResp.DisplayName)
|
||||
|
|
|
|||
|
|
@ -503,14 +503,8 @@ func mapFields(credentialResp *objectstorage.CreateAccessKeyResponse, model *Mod
|
|||
model.ExpirationTimestamp = types.StringValue(expirationTimestamp.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
idParts := []string{
|
||||
model.ProjectId.ValueString(),
|
||||
region,
|
||||
model.CredentialsGroupId.ValueString(),
|
||||
credentialId,
|
||||
}
|
||||
model.Id = types.StringValue(
|
||||
strings.Join(idParts, core.Separator),
|
||||
model.Id = utils.BuildInternalTerraformId(
|
||||
model.ProjectId.ValueString(), region, model.CredentialsGroupId.ValueString(), credentialId,
|
||||
)
|
||||
model.CredentialId = types.StringValue(credentialId)
|
||||
model.Name = types.StringPointerValue(credentialResp.DisplayName)
|
||||
|
|
@ -548,15 +542,7 @@ func readCredentials(ctx context.Context, model *Model, region string, client *o
|
|||
|
||||
foundCredential = true
|
||||
|
||||
idParts := []string{
|
||||
projectId,
|
||||
region,
|
||||
credentialsGroupId,
|
||||
credentialId,
|
||||
}
|
||||
model.Id = types.StringValue(
|
||||
strings.Join(idParts, core.Separator),
|
||||
)
|
||||
model.Id = utils.BuildInternalTerraformId(projectId, region, credentialsGroupId, credentialId)
|
||||
model.Name = types.StringPointerValue(credential.DisplayName)
|
||||
|
||||
if credential.Expires == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue