Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support process scoped variables #593

Merged
merged 17 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions docs/data-sources/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Optional:
- `channels` (List of String) A list of channels that are scoped to this variable value.
- `environments` (List of String) A list of environments that are scoped to this variable value.
- `machines` (List of String) A list of machines that are scoped to this variable value.
- `processes` (List of String) A list of processes that are scoped to this variable value.
- `roles` (List of String) A list of roles that are scoped to this variable value.
- `tenant_tags` (List of String) A list of tenant tags that are scoped to this variable value.

Expand Down
1 change: 1 addition & 0 deletions docs/resources/variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Optional:
- `channels` (List of String) A list of channels that are scoped to this variable value.
- `environments` (List of String) A list of environments that are scoped to this variable value.
- `machines` (List of String) A list of machines that are scoped to this variable value.
- `processes` (List of String) A list of processes that are scoped to this variable value.
- `roles` (List of String) A list of roles that are scoped to this variable value.
- `tenant_tags` (List of String) A list of tenant tags that are scoped to this variable value.

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.20

require (
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.1
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.2
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b
github.com/google/uuid v1.3.0
github.com/gruntwork-io/terratest v0.41.11
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
github.com/Microsoft/hcsshim v0.9.7 h1:mKNHW/Xvv1aFH87Jb6ERDzXTJTLPlmzfZ28VBFD/bfg=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.1 h1:irRBBh+rSCMqR0YDaUdfBnpl9UAU7tI8zD0j8xt2C8U=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.1/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.2 h1:ovLCSy+I1mN0nynxNtOkrxUuf4DL2jZc79kkBH6698g=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.36.2/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E=
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b h1:XOBPcVHeDUYIpcag0yI8IYKiBL+5LLL8suysvlavQwI=
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20230705105638-f5ef7c07973b/go.mod h1:E0hYVpZd61fXhzTozkxjiWEy+/yTRxAnr2SIE7k8ZSM=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ=
Expand Down
23 changes: 17 additions & 6 deletions octopusdeploy/schema_variable_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ func expandVariableScope(flattenedVariableScope interface{}) variables.VariableS

if flattenedMap, ok := list[0].(map[string]interface{}); ok {
return variables.VariableScope{
Actions: getSliceFromTerraformTypeList(flattenedMap["actions"]),
Channels: getSliceFromTerraformTypeList(flattenedMap["channels"]),
Environments: getSliceFromTerraformTypeList(flattenedMap["environments"]),
Machines: getSliceFromTerraformTypeList(flattenedMap["machines"]),
Roles: getSliceFromTerraformTypeList(flattenedMap["roles"]),
TenantTags: getSliceFromTerraformTypeList(flattenedMap["tenant_tags"]),
Actions: getSliceFromTerraformTypeList(flattenedMap["actions"]),
Channels: getSliceFromTerraformTypeList(flattenedMap["channels"]),
Environments: getSliceFromTerraformTypeList(flattenedMap["environments"]),
Machines: getSliceFromTerraformTypeList(flattenedMap["machines"]),
ProcessOwners: getSliceFromTerraformTypeList(flattenedMap["processes"]),
Roles: getSliceFromTerraformTypeList(flattenedMap["roles"]),
TenantTags: getSliceFromTerraformTypeList(flattenedMap["tenant_tags"]),
}
}

Expand Down Expand Up @@ -52,6 +53,10 @@ func flattenVariableScope(scope variables.VariableScope) []interface{} {
flattenedScope["machines"] = scope.Machines
}

if len(scope.ProcessOwners) > 0 {
flattenedScope["processes"] = scope.ProcessOwners
}

if len(scope.Roles) > 0 {
flattenedScope["roles"] = scope.Roles
}
Expand Down Expand Up @@ -89,6 +94,12 @@ func getVariableScopeSchema() map[string]*schema.Schema {
Optional: true,
Type: schema.TypeList,
},
"processes": {
Description: "A list of processes that are scoped to this variable value.",
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Type: schema.TypeList,
},
"roles": {
Description: "A list of roles that are scoped to this variable value.",
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down
Loading