diff --git a/docs/data-sources/lifecycles.md b/docs/data-sources/lifecycles.md index d7fb232f..12ec351b 100644 --- a/docs/data-sources/lifecycles.md +++ b/docs/data-sources/lifecycles.md @@ -58,6 +58,7 @@ Read-Only: - `automatic_deployment_targets` (List of String) The automatic deployment targets for this phase. - `id` (String) The ID of the phase. - `is_optional_phase` (Boolean) Whether this phase is optional. +- `is_priority_phase` (Boolean) Deployments will be prioritized in this phase - `minimum_environments_before_promotion` (Number) The minimum number of environments before promotion. - `name` (String) The name of the phase. - `optional_deployment_targets` (List of String) The optional deployment targets for this phase. diff --git a/docs/resources/lifecycle.md b/docs/resources/lifecycle.md index a311d478..4777c939 100644 --- a/docs/resources/lifecycle.md +++ b/docs/resources/lifecycle.md @@ -84,6 +84,7 @@ Optional: - `automatic_deployment_targets` (List of String) Environment IDs in this phase that a release is automatically deployed to when it is eligible for this phase - `id` (String) The unique ID for this resource. - `is_optional_phase` (Boolean) If false a release must be deployed to this phase before it can be deployed to the next phase. +- `is_priority_phase` (Boolean) Deployments will be prioritized in this phase - `minimum_environments_before_promotion` (Number) The number of units required before a release can enter the next phase. If 0, all environments are required. - `optional_deployment_targets` (List of String) Environment IDs in this phase that a release can be deployed to, but is not automatically deployed to - `release_retention_policy` (Block List) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--phase--release_retention_policy)) diff --git a/go.mod b/go.mod index 1a16e81b..28731613 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/OctopusDeploy/terraform-provider-octopusdeploy go 1.21 require ( - github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.0 + github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.1 github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4 github.com/google/uuid v1.6.0 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 diff --git a/go.sum b/go.sum index bfd0603f..03720a90 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/Microsoft/hcsshim v0.12.4 h1:Ev7YUMHAHoWNm+aDSPzc5W9s6E2jyL1szpVDJeZ/ github.com/Microsoft/hcsshim v0.12.4/go.mod h1:Iyl1WVpZzr+UkzjekHZbV8o5Z9ZkxNGx6CtY2Qg/JVQ= github.com/OctopusDeploy/go-octodiff v1.0.0 h1:U+ORg6azniwwYo+O44giOw6TiD5USk8S4VDhOQ0Ven0= github.com/OctopusDeploy/go-octodiff v1.0.0/go.mod h1:Mze0+EkOWTgTmi8++fyUc6r0aLZT7qD9gX+31t8MmIU= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.0 h1:X3Tdij/cGqmEtmZ0HqJFeHzTJVxFmYEAog4R4w6KFIw= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.0/go.mod h1:ggvOXzMnq+w0pLg6C9zdjz6YBaHfO3B3tqmmB7JQdaw= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.1 h1:GeWNIPn59JZggkjZD/VKpt3oJNuYezdJPbIqyl+MVRw= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.52.1/go.mod h1:ggvOXzMnq+w0pLg6C9zdjz6YBaHfO3B3tqmmB7JQdaw= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4 h1:QfbVf0bOIRMp/WHAWsuVDB7KHoWnRsGbvDuOf2ua7k4= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4/go.mod h1:Oq9KbiRNDBB5jFmrwnrgLX0urIqR/1ptY18TzkqXm7M= github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= diff --git a/octopusdeploy_framework/datasource_lifecycle.go b/octopusdeploy_framework/datasource_lifecycle.go index 5da184b8..cb46ff4d 100644 --- a/octopusdeploy_framework/datasource_lifecycle.go +++ b/octopusdeploy_framework/datasource_lifecycle.go @@ -117,6 +117,7 @@ func phaseObjectType() map[string]attr.Type { "optional_deployment_targets": types.ListType{ElemType: types.StringType}, "minimum_environments_before_promotion": types.Int64Type, "is_optional_phase": types.BoolType, + "is_priority_phase": types.BoolType, "release_retention_policy": types.ListType{ElemType: types.ObjectType{AttrTypes: retentionPolicyObjectType()}}, "tentacle_retention_policy": types.ListType{ElemType: types.ObjectType{AttrTypes: retentionPolicyObjectType()}}, } diff --git a/octopusdeploy_framework/resource_lifecycle.go b/octopusdeploy_framework/resource_lifecycle.go index 839a611f..3ab549f0 100644 --- a/octopusdeploy_framework/resource_lifecycle.go +++ b/octopusdeploy_framework/resource_lifecycle.go @@ -227,6 +227,7 @@ func flattenPhases(phases []*lifecycles.Phase) types.List { "optional_deployment_targets": util.FlattenStringList(phase.OptionalDeploymentTargets), "minimum_environments_before_promotion": types.Int64Value(int64(phase.MinimumEnvironmentsBeforePromotion)), "is_optional_phase": types.BoolValue(phase.IsOptionalPhase), + "is_priority_phase": types.BoolValue(phase.IsPriorityPhase), "release_retention_policy": util.Ternary(phase.ReleaseRetentionPolicy != nil, flattenRetentionPeriod(phase.ReleaseRetentionPolicy), types.ListNull(types.ObjectType{AttrTypes: getRetentionPeriodAttrTypes()})), "tentacle_retention_policy": util.Ternary(phase.TentacleRetentionPolicy != nil, flattenRetentionPeriod(phase.TentacleRetentionPolicy), types.ListNull(types.ObjectType{AttrTypes: getRetentionPeriodAttrTypes()})), } @@ -310,6 +311,10 @@ func expandPhases(phases types.List) []*lifecycles.Phase { phase.IsOptionalPhase = v.ValueBool() } + if v, ok := phaseAttrs["is_priority_phase"].(types.Bool); ok && !v.IsNull() { + phase.IsPriorityPhase = v.ValueBool() + } + if v, ok := phaseAttrs["release_retention_policy"].(types.List); ok && !v.IsNull() { phase.ReleaseRetentionPolicy = expandRetentionPeriod(v) } @@ -366,6 +371,7 @@ func getPhaseAttrTypes() map[string]attr.Type { "optional_deployment_targets": types.ListType{ElemType: types.StringType}, "minimum_environments_before_promotion": types.Int64Type, "is_optional_phase": types.BoolType, + "is_priority_phase": types.BoolType, "release_retention_policy": types.ListType{ElemType: types.ObjectType{AttrTypes: getRetentionPeriodAttrTypes()}}, "tentacle_retention_policy": types.ListType{ElemType: types.ObjectType{AttrTypes: getRetentionPeriodAttrTypes()}}, } diff --git a/octopusdeploy_framework/schemas/lifecycle.go b/octopusdeploy_framework/schemas/lifecycle.go index 2f4201d9..485b1af4 100644 --- a/octopusdeploy_framework/schemas/lifecycle.go +++ b/octopusdeploy_framework/schemas/lifecycle.go @@ -77,6 +77,11 @@ func getResourcePhaseBlockSchema() resourceSchema.ListNestedBlock { Default(booldefault.StaticBool(false)). Description("If false a release must be deployed to this phase before it can be deployed to the next phase."). Build(), + "is_priority_phase": util.ResourceBool(). + Optional().Computed(). + Default(booldefault.StaticBool(false)). + Description("Deployments will be prioritized in this phase"). + Build(), }, Blocks: map[string]resourceSchema.Block{ "release_retention_policy": getResourceRetentionPolicyBlockSchema(), @@ -144,6 +149,7 @@ func getPhasesAttribute() datasourceSchema.ListNestedAttribute { "optional_deployment_targets": util.DataSourceList(types.StringType).Computed().Description("The optional deployment targets for this phase.").Build(), "minimum_environments_before_promotion": util.DataSourceInt64().Computed().Description("The minimum number of environments before promotion.").Build(), "is_optional_phase": util.DataSourceBool().Computed().Description("Whether this phase is optional.").Build(), + "is_priority_phase": util.DataSourceBool().Computed().Description("Deployments will be prioritized in this phase").Build(), "release_retention_policy": getRetentionPolicyAttribute(), "tentacle_retention_policy": getRetentionPolicyAttribute(), },