Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions octopusdeploy_framework/resource_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
7 changes: 4 additions & 3 deletions octopusdeploy_framework/schemas/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{}
Expand Down Expand Up @@ -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()

Expand All @@ -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(
Expand Down
Loading