Skip to content

Commit

Permalink
feat: lifecycle phase priority support (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
domenicsim1 authored Oct 16, 2024
1 parent 337f569 commit 381d471
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/lifecycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/datasource_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}},
}
Expand Down
6 changes: 6 additions & 0 deletions octopusdeploy_framework/resource_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()})),
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()}},
}
Expand Down
6 changes: 6 additions & 0 deletions octopusdeploy_framework/schemas/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
},
Expand Down

0 comments on commit 381d471

Please sign in to comment.