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:
parent
4917eda1ad
commit
18d3f4d1fb
22 changed files with 262 additions and 284 deletions
|
|
@ -123,7 +123,11 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
|
|||
"http_api_uri": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"name": schema.StringAttribute{
|
||||
"http_api_uris": schema.ListAttribute{
|
||||
ElementType: types.StringType,
|
||||
Computed: true,
|
||||
},
|
||||
"management": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"password": schema.StringAttribute{
|
||||
|
|
@ -136,6 +140,10 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
|
|||
"uri": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"uris": schema.ListAttribute{
|
||||
ElementType: types.StringType,
|
||||
Computed: true,
|
||||
},
|
||||
"username": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ type Model struct {
|
|||
Host types.String `tfsdk:"host"`
|
||||
Hosts types.List `tfsdk:"hosts"`
|
||||
HttpAPIURI types.String `tfsdk:"http_api_uri"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
HttpAPIURIs types.List `tfsdk:"http_api_uris"`
|
||||
Management types.String `tfsdk:"management"`
|
||||
Password types.String `tfsdk:"password"`
|
||||
Port types.Int64 `tfsdk:"port"`
|
||||
Uri types.String `tfsdk:"uri"`
|
||||
Uris types.List `tfsdk:"uris"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +162,11 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
|
|||
"http_api_uri": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"name": schema.StringAttribute{
|
||||
"http_api_uris": schema.ListAttribute{
|
||||
ElementType: types.StringType,
|
||||
Computed: true,
|
||||
},
|
||||
"management": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"password": schema.StringAttribute{
|
||||
|
|
@ -173,6 +179,10 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
|
|||
"uri": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"uris": schema.ListAttribute{
|
||||
ElementType: types.StringType,
|
||||
Computed: true,
|
||||
},
|
||||
"username": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
|
@ -347,6 +357,8 @@ func mapFields(credentialsResp *rabbitmq.CredentialsResponse, model *Model) erro
|
|||
)
|
||||
model.CredentialId = types.StringValue(credentialId)
|
||||
model.Hosts = types.ListNull(types.StringType)
|
||||
model.Uris = types.ListNull(types.StringType)
|
||||
model.HttpAPIURIs = types.ListNull(types.StringType)
|
||||
if credentials != nil {
|
||||
if credentials.Hosts != nil {
|
||||
var hosts []attr.Value
|
||||
|
|
@ -360,10 +372,32 @@ func mapFields(credentialsResp *rabbitmq.CredentialsResponse, model *Model) erro
|
|||
model.Hosts = hostsList
|
||||
}
|
||||
model.Host = types.StringPointerValue(credentials.Host)
|
||||
if credentials.HttpApiUris != nil {
|
||||
var httpApiUris []attr.Value
|
||||
for _, httpApiUri := range *credentials.HttpApiUris {
|
||||
httpApiUris = append(httpApiUris, types.StringValue(httpApiUri))
|
||||
}
|
||||
httpApiUrisList, diags := types.ListValue(types.StringType, httpApiUris)
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed to map httpApiUris: %w", core.DiagsToError(diags))
|
||||
}
|
||||
model.HttpAPIURIs = httpApiUrisList
|
||||
}
|
||||
model.HttpAPIURI = types.StringPointerValue(credentials.HttpApiUri)
|
||||
model.Name = types.StringPointerValue(credentials.Name)
|
||||
model.Management = types.StringPointerValue(credentials.Management)
|
||||
model.Password = types.StringPointerValue(credentials.Password)
|
||||
model.Port = types.Int64PointerValue(credentials.Port)
|
||||
if credentials.Uris != nil {
|
||||
var uris []attr.Value
|
||||
for _, uri := range *credentials.Uris {
|
||||
uris = append(uris, types.StringValue(uri))
|
||||
}
|
||||
urisList, diags := types.ListValue(types.StringType, uris)
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed to map uris: %w", core.DiagsToError(diags))
|
||||
}
|
||||
model.Uris = urisList
|
||||
}
|
||||
model.Uri = types.StringPointerValue(credentials.Uri)
|
||||
model.Username = types.StringPointerValue(credentials.Username)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,12 @@ func TestMapFields(t *testing.T) {
|
|||
Host: types.StringNull(),
|
||||
Hosts: types.ListNull(types.StringType),
|
||||
HttpAPIURI: types.StringNull(),
|
||||
Name: types.StringNull(),
|
||||
HttpAPIURIs: types.ListNull(types.StringType),
|
||||
Management: types.StringNull(),
|
||||
Password: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Uri: types.StringNull(),
|
||||
Uris: types.ListNull(types.StringType),
|
||||
Username: types.StringNull(),
|
||||
},
|
||||
true,
|
||||
|
|
@ -51,11 +53,19 @@ func TestMapFields(t *testing.T) {
|
|||
"",
|
||||
},
|
||||
HttpApiUri: utils.Ptr("http"),
|
||||
Name: utils.Ptr("name"),
|
||||
HttpApiUris: &[]string{
|
||||
"http_api_uri_1",
|
||||
"",
|
||||
},
|
||||
Management: utils.Ptr("management"),
|
||||
Password: utils.Ptr("password"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Uri: utils.Ptr("uri"),
|
||||
Username: utils.Ptr("username"),
|
||||
Uris: &[]string{
|
||||
"uri_1",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -70,11 +80,19 @@ func TestMapFields(t *testing.T) {
|
|||
types.StringValue(""),
|
||||
}),
|
||||
HttpAPIURI: types.StringValue("http"),
|
||||
Name: types.StringValue("name"),
|
||||
HttpAPIURIs: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("http_api_uri_1"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
Management: types.StringValue("management"),
|
||||
Password: types.StringValue("password"),
|
||||
Port: types.Int64Value(1234),
|
||||
Uri: types.StringValue("uri"),
|
||||
Username: types.StringValue("username"),
|
||||
Uris: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("uri_1"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
Username: types.StringValue("username"),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -84,14 +102,16 @@ func TestMapFields(t *testing.T) {
|
|||
Id: utils.Ptr("cid"),
|
||||
Raw: &rabbitmq.RawCredentials{
|
||||
Credentials: &rabbitmq.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{},
|
||||
HttpApiUri: nil,
|
||||
HttpApiUris: &[]string{},
|
||||
Management: nil,
|
||||
Password: utils.Ptr(""),
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
Uri: nil,
|
||||
Uris: &[]string{},
|
||||
Username: utils.Ptr(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -103,10 +123,12 @@ func TestMapFields(t *testing.T) {
|
|||
Host: types.StringValue(""),
|
||||
Hosts: types.ListValueMust(types.StringType, []attr.Value{}),
|
||||
HttpAPIURI: types.StringNull(),
|
||||
Name: types.StringNull(),
|
||||
HttpAPIURIs: types.ListValueMust(types.StringType, []attr.Value{}),
|
||||
Management: types.StringNull(),
|
||||
Password: types.StringValue(""),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Uri: types.StringNull(),
|
||||
Uris: types.ListValueMust(types.StringType, []attr.Value{}),
|
||||
Username: types.StringValue(""),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ var instanceResource = map[string]string{
|
|||
"project_id": testutil.ProjectId,
|
||||
"name": testutil.ResourceNameWithDateTime("rabbitmq"),
|
||||
"plan_id": "7e1f8394-5dd5-40b1-8608-16b4344eb51b",
|
||||
"plan_name": "stackit-qa-rabbitmq-2.4.10-single",
|
||||
"plan_name": "stackit-rabbitmq-2.4.10-single",
|
||||
"version": "3.10",
|
||||
"sgw_acl_invalid": "1.2.3.4/4",
|
||||
"sgw_acl_valid": "192.168.0.0/16",
|
||||
|
|
@ -166,6 +166,8 @@ func TestAccRabbitMQResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credential", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credential", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credential", "uri"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credential", "management"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credential", "http_api_uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -229,7 +231,9 @@ func testAccCheckRabbitMQDestroy(s *terraform.State) error {
|
|||
var client *rabbitmq.APIClient
|
||||
var err error
|
||||
if testutil.RabbitMQCustomEndpoint == "" {
|
||||
client, err = rabbitmq.NewAPIClient()
|
||||
client, err = rabbitmq.NewAPIClient(
|
||||
config.WithRegion("eu01"),
|
||||
)
|
||||
} else {
|
||||
client, err = rabbitmq.NewAPIClient(
|
||||
config.WithEndpoint(testutil.RabbitMQCustomEndpoint),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue