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

@ -121,10 +121,7 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
ElementType: types.StringType,
Computed: true,
},
"http_api_uri": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
"load_balanced_host": schema.StringAttribute{
Computed: true,
},
"password": schema.StringAttribute{

View file

@ -30,18 +30,17 @@ var (
)
type Model struct {
Id types.String `tfsdk:"id"` // needed by TF
CredentialId types.String `tfsdk:"credential_id"`
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"`
Username types.String `tfsdk:"username"`
Id types.String `tfsdk:"id"` // needed by TF
CredentialId types.String `tfsdk:"credential_id"`
InstanceId types.String `tfsdk:"instance_id"`
ProjectId types.String `tfsdk:"project_id"`
Host types.String `tfsdk:"host"`
Hosts types.List `tfsdk:"hosts"`
LoadBalancedHost types.String `tfsdk:"load_balanced_host"`
Password types.String `tfsdk:"password"`
Port types.Int64 `tfsdk:"port"`
Uri types.String `tfsdk:"uri"`
Username types.String `tfsdk:"username"`
}
// NewCredentialResource is a helper function to simplify the provider implementation.
@ -158,10 +157,7 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
ElementType: types.StringType,
Computed: true,
},
"http_api_uri": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
"load_balanced_host": schema.StringAttribute{
Computed: true,
},
"password": schema.StringAttribute{
@ -362,8 +358,7 @@ func mapFields(credentialsResp *redis.CredentialsResponse, model *Model) error {
model.Hosts = hostsList
}
model.Host = types.StringPointerValue(credentials.Host)
model.HttpAPIURI = types.StringPointerValue(credentials.HttpApiUri)
model.Name = types.StringPointerValue(credentials.Name)
model.LoadBalancedHost = types.StringPointerValue(credentials.LoadBalancedHost)
model.Password = types.StringPointerValue(credentials.Password)
model.Port = types.Int64PointerValue(credentials.Port)
model.Uri = types.StringPointerValue(credentials.Uri)

View file

@ -24,18 +24,17 @@ func TestMapFields(t *testing.T) {
Raw: &redis.RawCredentials{},
},
Model{
Id: types.StringValue("pid,iid,cid"),
CredentialId: types.StringValue("cid"),
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(),
Username: types.StringNull(),
Id: types.StringValue("pid,iid,cid"),
CredentialId: types.StringValue("cid"),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Host: types.StringNull(),
Hosts: types.ListNull(types.StringType),
LoadBalancedHost: types.StringNull(),
Password: types.StringNull(),
Port: types.Int64Null(),
Uri: types.StringNull(),
Username: types.StringNull(),
},
true,
},
@ -50,12 +49,11 @@ func TestMapFields(t *testing.T) {
"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"),
LoadBalancedHost: utils.Ptr("load_balanced_host"),
Password: utils.Ptr("password"),
Port: utils.Ptr(int64(1234)),
Uri: utils.Ptr("uri"),
Username: utils.Ptr("username"),
},
},
},
@ -69,12 +67,11 @@ func TestMapFields(t *testing.T) {
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"),
LoadBalancedHost: types.StringValue("load_balanced_host"),
Password: types.StringValue("password"),
Port: types.Int64Value(1234),
Uri: types.StringValue("uri"),
Username: types.StringValue("username"),
},
true,
},
@ -84,30 +81,28 @@ func TestMapFields(t *testing.T) {
Id: utils.Ptr("cid"),
Raw: &redis.RawCredentials{
Credentials: &redis.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(""),
Hosts: &[]string{},
LoadBalancedHost: nil,
Password: utils.Ptr(""),
Port: utils.Ptr(int64(2123456789)),
Uri: nil,
Username: utils.Ptr(""),
},
},
},
Model{
Id: types.StringValue("pid,iid,cid"),
CredentialId: types.StringValue("cid"),
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(),
Username: types.StringValue(""),
Id: types.StringValue("pid,iid,cid"),
CredentialId: types.StringValue("cid"),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Host: types.StringValue(""),
Hosts: types.ListValueMust(types.StringType, []attr.Value{}),
LoadBalancedHost: types.StringNull(),
Password: types.StringValue(""),
Port: types.Int64Value(2123456789),
Uri: types.StringNull(),
Username: types.StringValue(""),
},
true,
},

View file

@ -22,7 +22,7 @@ var instanceResource = map[string]string{
"project_id": testutil.ProjectId,
"name": testutil.ResourceNameWithDateTime("redis"),
"plan_id": "96e24604-7a43-4ff8-9ba4-609d4235a137",
"plan_name": "stackit-qa-redis-1.4.10-single",
"plan_name": "stackit-redis-1.4.10-single",
"version": "6",
"sgw_acl_invalid": "1.2.3.4/4",
"sgw_acl_valid": "192.168.0.0/16",
@ -166,6 +166,7 @@ func TestAccRedisResource(t *testing.T) {
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credential", "host"),
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credential", "port"),
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credential", "uri"),
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credential", "load_balanced_host"),
),
},
// Import
@ -244,7 +245,9 @@ func testAccCheckRedisDestroy(s *terraform.State) error {
var client *redis.APIClient
var err error
if testutil.RedisCustomEndpoint == "" {
client, err = redis.NewAPIClient()
client, err = redis.NewAPIClient(
config.WithRegion("eu01"),
)
} else {
client, err = redis.NewAPIClient(
config.WithEndpoint(testutil.RedisCustomEndpoint),