From c226b8122f4cb696824118ba9b527d1357149400 Mon Sep 17 00:00:00 2001 From: Tiago Carreira Date: Tue, 1 Jul 2025 11:40:05 +0100 Subject: [PATCH 1/2] remove unused function --- octopusdeploy_framework/resource_lifecycle.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/octopusdeploy_framework/resource_lifecycle.go b/octopusdeploy_framework/resource_lifecycle.go index 3ab549f0a..f33731a5f 100644 --- a/octopusdeploy_framework/resource_lifecycle.go +++ b/octopusdeploy_framework/resource_lifecycle.go @@ -187,17 +187,6 @@ func resourceConfiguration(req resource.ConfigureRequest, resp *resource.Configu return p } -func setDefaultRetentionPolicies(data *lifecycleTypeResourceModel) { - defaultPolicy := flattenRetentionPeriod(core.NewRetentionPeriod(30, "Days", false)) - - if data.ReleaseRetentionPolicy.IsNull() || len(data.ReleaseRetentionPolicy.Elements()) == 0 { - data.ReleaseRetentionPolicy = defaultPolicy - } - - if data.TentacleRetentionPolicy.IsNull() || len(data.TentacleRetentionPolicy.Elements()) == 0 { - data.TentacleRetentionPolicy = defaultPolicy - } -} func flattenLifecycleResource(lifecycle *lifecycles.Lifecycle) *lifecycleTypeResourceModel { flattenedLifecycle := &lifecycleTypeResourceModel{ From acb925f10fa67d753f3392b37167be515612d614 Mon Sep 17 00:00:00 2001 From: Tiago Carreira Date: Tue, 1 Jul 2025 11:41:11 +0100 Subject: [PATCH 2/2] skip lifecycle validation if IsUnknown() --- octopusdeploy_framework/schemas/lifecycle.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/octopusdeploy_framework/schemas/lifecycle.go b/octopusdeploy_framework/schemas/lifecycle.go index 6a51b2d9f..c38f929c8 100644 --- a/octopusdeploy_framework/schemas/lifecycle.go +++ b/octopusdeploy_framework/schemas/lifecycle.go @@ -2,6 +2,8 @@ package schemas import ( "context" + "strings" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -16,7 +18,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" - "strings" ) var _ EntitySchema = LifecycleSchema{} @@ -205,7 +206,7 @@ func (v retentionPolicyValidator) ValidateObject(ctx context.Context, req valida return } - if !retentionPolicy.QuantityToKeep.IsNull() && !retentionPolicy.ShouldKeepForever.IsNull() { + if !retentionPolicy.QuantityToKeep.IsNull() && !retentionPolicy.QuantityToKeep.IsUnknown() && !retentionPolicy.ShouldKeepForever.IsNull() && !retentionPolicy.ShouldKeepForever.IsUnknown() { quantityToKeep := retentionPolicy.QuantityToKeep.ValueInt64() shouldKeepForever := retentionPolicy.ShouldKeepForever.ValueBool() @@ -224,7 +225,7 @@ func (v retentionPolicyValidator) ValidateObject(ctx context.Context, req valida } } - if !retentionPolicy.Unit.IsNull() { + if !retentionPolicy.Unit.IsNull() && !retentionPolicy.Unit.IsUnknown() { unit := retentionPolicy.Unit.ValueString() if !strings.EqualFold(unit, "Days") && !strings.EqualFold(unit, "Items") { resp.Diagnostics.AddAttributeError(