From dfc9e391d580b4855c04e340bdec5282f1e2e192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Wed, 31 Jan 2024 09:05:48 +0000 Subject: [PATCH] Fix Argus Scrape Config SAML2 field default (#239) * Fix Argus Scrape Config SAML2 field default * Adjust acceptance test --- stackit/internal/services/argus/argus_acc_test.go | 3 +++ .../services/argus/scrapeconfig/datasource.go | 4 ++-- .../services/argus/scrapeconfig/resource.go | 14 +++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/stackit/internal/services/argus/argus_acc_test.go b/stackit/internal/services/argus/argus_acc_test.go index 62227e34..7a45b834 100644 --- a/stackit/internal/services/argus/argus_acc_test.go +++ b/stackit/internal/services/argus/argus_acc_test.go @@ -278,6 +278,9 @@ func TestAccResource(t *testing.T) { scrape_interval = "%s" sample_limit = %s metrics_path = "%s" + saml2 = { + enable_url_parameters = false + } } `, testutil.ArgusProviderConfig(), diff --git a/stackit/internal/services/argus/scrapeconfig/datasource.go b/stackit/internal/services/argus/scrapeconfig/datasource.go index d3c83c5c..fd9937fb 100644 --- a/stackit/internal/services/argus/scrapeconfig/datasource.go +++ b/stackit/internal/services/argus/scrapeconfig/datasource.go @@ -136,11 +136,11 @@ func (d *scrapeConfigDataSource) Schema(_ context.Context, _ datasource.SchemaRe Computed: true, }, "saml2": schema.SingleNestedAttribute{ - Description: "A SAML2 configuration block", + Description: "A SAML2 configuration block.", Computed: true, Attributes: map[string]schema.Attribute{ "enable_url_parameters": schema.BoolAttribute{ - Description: "Are URL parameters be enabled?", + Description: "Specifies if URL parameters are enabled", Computed: true, }, }, diff --git a/stackit/internal/services/argus/scrapeconfig/resource.go b/stackit/internal/services/argus/scrapeconfig/resource.go index 078c8c5b..80b0bd20 100644 --- a/stackit/internal/services/argus/scrapeconfig/resource.go +++ b/stackit/internal/services/argus/scrapeconfig/resource.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" @@ -214,9 +215,20 @@ func (r *scrapeConfigResource) Schema(_ context.Context, _ resource.SchemaReques "saml2": schema.SingleNestedAttribute{ Description: "A SAML2 configuration block.", Optional: true, + Computed: true, + Default: objectdefault.StaticValue( + types.ObjectValueMust( + map[string]attr.Type{ + "enable_url_parameters": types.BoolType, + }, + map[string]attr.Value{ + "enable_url_parameters": types.BoolValue(DefaultSAML2EnableURLParameters), + }, + ), + ), Attributes: map[string]schema.Attribute{ "enable_url_parameters": schema.BoolAttribute{ - Description: "Are URL parameters be enabled?", + Description: "Specifies if URL parameters are enabled.", Optional: true, Computed: true, Default: booldefault.StaticBool(DefaultSAML2EnableURLParameters),