fix(deps): update stackit sdk modules (#327)

* fix(deps): update stackit sdk modules

* remove deprecated fields from credentials resources

* remove deprecated fields from credentials resources

* add newly added fields to credentials resources

* remove deprecated fields from credentials datasource

* add newly added credential fields to datasources

* update acceptance tests

---------

Co-authored-by: Renovate Bot <renovate@whitesourcesoftware.com>
Co-authored-by: Gökçe Gök Klingel <goekce.goek_klingel@mail.schwarz>
This commit is contained in:
stackit-pipeline 2024-04-15 09:52:35 +02:00 committed by GitHub
parent 4917eda1ad
commit 18d3f4d1fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 262 additions and 284 deletions

View file

@ -11,7 +11,6 @@ import (
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/services/logme"
)
@ -116,16 +115,6 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
"host": schema.StringAttribute{
Computed: true,
},
"hosts": schema.ListAttribute{
ElementType: types.StringType,
Computed: true,
},
"http_api_uri": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"password": schema.StringAttribute{
Computed: true,
Sensitive: true,

View file

@ -10,7 +10,6 @@ import (
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
@ -35,9 +34,6 @@ type Model struct {
InstanceId types.String `tfsdk:"instance_id"`
ProjectId types.String `tfsdk:"project_id"`
Host types.String `tfsdk:"host"`
Hosts types.List `tfsdk:"hosts"`
HttpAPIURI types.String `tfsdk:"http_api_uri"`
Name types.String `tfsdk:"name"`
Password types.String `tfsdk:"password"`
Port types.Int64 `tfsdk:"port"`
Uri types.String `tfsdk:"uri"`
@ -153,16 +149,6 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
"host": schema.StringAttribute{
Computed: true,
},
"hosts": schema.ListAttribute{
ElementType: types.StringType,
Computed: true,
},
"http_api_uri": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"password": schema.StringAttribute{
Computed: true,
Sensitive: true,
@ -346,22 +332,8 @@ func mapFields(credentialsResp *logme.CredentialsResponse, model *Model) error {
strings.Join(idParts, core.Separator),
)
model.CredentialId = types.StringValue(credentialId)
model.Hosts = types.ListNull(types.StringType)
if credentials != nil {
if credentials.Hosts != nil {
var hosts []attr.Value
for _, host := range *credentials.Hosts {
hosts = append(hosts, types.StringValue(host))
}
hostsList, diags := types.ListValue(types.StringType, hosts)
if diags.HasError() {
return fmt.Errorf("failed to map hosts: %w", core.DiagsToError(diags))
}
model.Hosts = hostsList
}
model.Host = types.StringPointerValue(credentials.Host)
model.HttpAPIURI = types.StringPointerValue(credentials.HttpApiUri)
model.Name = types.StringPointerValue(credentials.Name)
model.Password = types.StringPointerValue(credentials.Password)
model.Port = types.Int64PointerValue(credentials.Port)
model.Uri = types.StringPointerValue(credentials.Uri)

View file

@ -4,7 +4,6 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/logme"
@ -29,9 +28,6 @@ func TestMapFields(t *testing.T) {
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Host: types.StringNull(),
Hosts: types.ListNull(types.StringType),
HttpAPIURI: types.StringNull(),
Name: types.StringNull(),
Password: types.StringNull(),
Port: types.Int64Null(),
Uri: types.StringNull(),
@ -45,17 +41,11 @@ func TestMapFields(t *testing.T) {
Id: utils.Ptr("cid"),
Raw: &logme.RawCredentials{
Credentials: &logme.Credentials{
Host: utils.Ptr("host"),
Hosts: &[]string{
"host_1",
"",
},
HttpApiUri: utils.Ptr("http"),
Name: utils.Ptr("name"),
Password: utils.Ptr("password"),
Port: utils.Ptr(int64(1234)),
Uri: utils.Ptr("uri"),
Username: utils.Ptr("username"),
Host: utils.Ptr("host"),
Password: utils.Ptr("password"),
Port: utils.Ptr(int64(1234)),
Uri: utils.Ptr("uri"),
Username: utils.Ptr("username"),
},
},
},
@ -65,16 +55,10 @@ func TestMapFields(t *testing.T) {
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Host: types.StringValue("host"),
Hosts: types.ListValueMust(types.StringType, []attr.Value{
types.StringValue("host_1"),
types.StringValue(""),
}),
HttpAPIURI: types.StringValue("http"),
Name: types.StringValue("name"),
Password: types.StringValue("password"),
Port: types.Int64Value(1234),
Uri: types.StringValue("uri"),
Username: types.StringValue("username"),
Password: types.StringValue("password"),
Port: types.Int64Value(1234),
Uri: types.StringValue("uri"),
Username: types.StringValue("username"),
},
true,
},
@ -84,14 +68,11 @@ func TestMapFields(t *testing.T) {
Id: utils.Ptr("cid"),
Raw: &logme.RawCredentials{
Credentials: &logme.Credentials{
Host: utils.Ptr(""),
Hosts: &[]string{},
HttpApiUri: nil,
Name: nil,
Password: utils.Ptr(""),
Port: utils.Ptr(int64(2123456789)),
Uri: nil,
Username: utils.Ptr(""),
Host: utils.Ptr(""),
Password: utils.Ptr(""),
Port: utils.Ptr(int64(2123456789)),
Uri: nil,
Username: utils.Ptr(""),
},
},
},
@ -101,9 +82,6 @@ func TestMapFields(t *testing.T) {
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Host: types.StringValue(""),
Hosts: types.ListValueMust(types.StringType, []attr.Value{}),
HttpAPIURI: types.StringNull(),
Name: types.StringNull(),
Password: types.StringValue(""),
Port: types.Int64Value(2123456789),
Uri: types.StringNull(),

View file

@ -21,7 +21,7 @@ var instanceResource = map[string]string{
"project_id": testutil.ProjectId,
"name": testutil.ResourceNameWithDateTime("logme"),
"plan_id": "201d743c-0f06-4af2-8f20-649baf4819ae",
"plan_name": "stackit-qa-logme2-1.2.50-replica",
"plan_name": "stackit-logme2-1.2.50-replica",
"version": "2",
"sgw_acl-1": "192.168.0.0/16",
"sgw_acl-2": "192.168.0.0/24",
@ -184,7 +184,9 @@ func testAccCheckLogMeDestroy(s *terraform.State) error {
var client *logme.APIClient
var err error
if testutil.LogMeCustomEndpoint == "" {
client, err = logme.NewAPIClient()
client, err = logme.NewAPIClient(
config.WithRegion("eu01"),
)
} else {
client, err = logme.NewAPIClient(
config.WithEndpoint(testutil.LogMeCustomEndpoint),