diff --git a/go.mod b/go.mod index 2ea550f2e..8ab7940c8 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.41.0 + github.com/OctopusDeploy/go-octopusdeploy/v2 v2.41.1 github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240409225949-b27d14ff2bcb github.com/google/uuid v1.6.0 github.com/gruntwork-io/terratest v0.41.11 diff --git a/go.sum b/go.sum index a32f09ddf..5676603e5 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.41.0 h1:11fXSFfz0YQ9/e4KX7v7XW99z2+Q8qgyL9Z9E195YgM= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.41.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.41.1 h1:CpKfSXxI8HlwD6wOY4x2jpRHjQCZNssHZ5qr0HyB7PQ= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.41.1/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240409225949-b27d14ff2bcb h1:4Lzs6TsvSZkahw99VlIDP5aAihQiJZPoCQKTw1A9el4= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240409225949-b27d14ff2bcb/go.mod h1:Nyg+7cyTrSQ/lMIy5YY1UdJekRuoMWf4uHIPfaGmgTM= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= diff --git a/integration_test.go b/integration_test.go index 79808fcfb..f4b971683 100644 --- a/integration_test.go +++ b/integration_test.go @@ -3553,18 +3553,20 @@ func TestPackageFeedCreateReleaseTriggerResources(t *testing.T) { return err } - if len(project_triggers) != 2 { - t.Fatal("There must be exactly 2 project triggers") + if len(project_triggers) != 3 { + t.Fatal("There must be exactly 3 project triggers") } tr1Name := "My first trigger" tr2Name := "My second trigger" + tr3Name := "My third trigger" tr1Index := stdslices.IndexFunc(project_triggers, func(t *triggers.ProjectTrigger) bool { return t.Name == tr1Name }) tr2Index := stdslices.IndexFunc(project_triggers, func(t *triggers.ProjectTrigger) bool { return t.Name == tr2Name }) + tr3Index := stdslices.IndexFunc(project_triggers, func(t *triggers.ProjectTrigger) bool { return t.Name == tr3Name }) - if tr1Index == -1 || tr2Index == -1 { - t.Fatalf("Unable to find both triggers. Expecting there to be \"%s\" and \"%s\".", tr1Name, tr2Name) + if tr1Index == -1 || tr2Index == -1 || tr3Index == -1 { + t.Fatalf("Unable to find all triggers. Expecting there to be \"%s\", \"%s\", and \"%s\".", tr1Name, tr2Name, tr3Name) } if project_triggers[0].Filter.GetFilterType() != filters.FeedFilter || project_triggers[1].Filter.GetFilterType() != filters.FeedFilter { @@ -3579,8 +3581,13 @@ func TestPackageFeedCreateReleaseTriggerResources(t *testing.T) { t.Fatalf("The trigger \"%s\" should be disabled", tr2Name) } + if project_triggers[tr3Index].IsDisabled { + t.Fatalf("The trigger \"%s\" should not be disabled", tr3Name) + } + tr1Filter := project_triggers[tr1Index].Filter.(*filters.FeedTriggerFilter) tr2Filter := project_triggers[tr2Index].Filter.(*filters.FeedTriggerFilter) + tr3Filter := project_triggers[tr3Index].Filter.(*filters.FeedTriggerFilter) if len(tr1Filter.Packages) != 2 { t.Fatalf("The trigger \"%s\" should have 2 package references", tr1Name) @@ -3590,6 +3597,10 @@ func TestPackageFeedCreateReleaseTriggerResources(t *testing.T) { t.Fatalf("The trigger \"%s\" should have 1 package reference", tr2Name) } + if len(tr3Filter.Packages) != 3 { + t.Fatalf("The trigger \"%s\" should have 3 package reference", tr3Name) + } + return nil }) } diff --git a/terraform/52-packagefeedcreatereleasetrigger/deployment_process.tf b/terraform/52-packagefeedcreatereleasetrigger/deployment_process.tf index 48b0aac30..be2e90124 100644 --- a/terraform/52-packagefeedcreatereleasetrigger/deployment_process.tf +++ b/terraform/52-packagefeedcreatereleasetrigger/deployment_process.tf @@ -65,4 +65,82 @@ resource "octopusdeploy_deployment_process" "example" { } } } + step { + condition = "Success" + name = "Helm one" + package_requirement = "LetOctopusDecide" + start_trigger = "StartAfterPrevious" + + action { + action_type = "Octopus.HelmChartUpgrade" + name = "Helm one" + condition = "Success" + run_on_server = true + is_disabled = false + can_be_used_for_project_versioning = true + is_required = false + worker_pool_id = "" + properties = { + "Octopus.Action.Helm.ClientVersion" = "V3" + "Octopus.Action.Helm.Namespace" = "dev" + "Octopus.Action.Package.DownloadOnTentacle" = "False" + "Octopus.Action.Helm.ResetValues" = "True" + } + environments = [] + excluded_environments = [] + channels = [] + tenant_tags = [] + + primary_package { + package_id = "redis" + acquisition_location = "Server" + feed_id = "${octopusdeploy_helm_feed.feed_helm_charts.id}" + properties = { SelectionMode = "immediate" } + } + + features = [] + } + + properties = {} + target_roles = ["k8s"] + } + step { + condition = "Success" + name = "Helm two" + package_requirement = "LetOctopusDecide" + start_trigger = "StartAfterPrevious" + + action { + action_type = "Octopus.HelmChartUpgrade" + name = "Helm two" + condition = "Success" + run_on_server = true + is_disabled = false + can_be_used_for_project_versioning = true + is_required = false + worker_pool_id = "" + properties = { + "Octopus.Action.Helm.ClientVersion" = "V3" + "Octopus.Action.Helm.Namespace" = "dev" + "Octopus.Action.Package.DownloadOnTentacle" = "False" + "Octopus.Action.Helm.ResetValues" = "True" + } + environments = [] + excluded_environments = [] + channels = [] + tenant_tags = [] + + primary_package { + package_id = "prometheus" + acquisition_location = "Server" + feed_id = "${octopusdeploy_helm_feed.feed_helm_charts.id}" + properties = { SelectionMode = "immediate" } + } + + features = [] + } + + properties = {} + target_roles = ["k8s"] + } } diff --git a/terraform/52-packagefeedcreatereleasetrigger/feed.tf b/terraform/52-packagefeedcreatereleasetrigger/feed.tf index bef8fdfeb..aae2d7f88 100644 --- a/terraform/52-packagefeedcreatereleasetrigger/feed.tf +++ b/terraform/52-packagefeedcreatereleasetrigger/feed.tf @@ -1,4 +1,10 @@ resource "octopusdeploy_docker_container_registry" "docker_feed" { feed_uri = "https://index.docker.io" name = "Test Docker Container Registry" -} \ No newline at end of file +} + +resource "octopusdeploy_helm_feed" "feed_helm_charts" { + name = "Test Helm Charts" + feed_uri = "https://charts.helm.sh/stable" + package_acquisition_location_options = ["ExecutionTarget", "NotAcquired"] +} diff --git a/terraform/52-packagefeedcreatereleasetrigger/project.tf b/terraform/52-packagefeedcreatereleasetrigger/project.tf index 494b9526c..3a62b322c 100644 --- a/terraform/52-packagefeedcreatereleasetrigger/project.tf +++ b/terraform/52-packagefeedcreatereleasetrigger/project.tf @@ -10,8 +10,22 @@ resource "octopusdeploy_project_group" "project_group_test" { description = "Test Description" } -resource "octopusdeploy_channel" "test_channel" { - name = "Test Channel" +resource "octopusdeploy_channel" "test_channel_1" { + name = "Test Channel 1" + project_id = "${octopusdeploy_project.deploy_frontend_project.id}" + space_id = var.octopus_space_id + lifecycle_id = data.octopusdeploy_lifecycles.lifecycle_default_lifecycle.lifecycles[0].id +} + +resource "octopusdeploy_channel" "test_channel_2" { + name = "Test Channel 2" + project_id = "${octopusdeploy_project.deploy_frontend_project.id}" + space_id = var.octopus_space_id + lifecycle_id = data.octopusdeploy_lifecycles.lifecycle_default_lifecycle.lifecycles[0].id +} + +resource "octopusdeploy_channel" "test_channel_3" { + name = "Test Channel 3" project_id = "${octopusdeploy_project.deploy_frontend_project.id}" space_id = var.octopus_space_id lifecycle_id = data.octopusdeploy_lifecycles.lifecycle_default_lifecycle.lifecycles[0].id diff --git a/terraform/52-packagefeedcreatereleasetrigger/project_triggers.tf b/terraform/52-packagefeedcreatereleasetrigger/project_triggers.tf index 50a98acb4..4bee6ec44 100644 --- a/terraform/52-packagefeedcreatereleasetrigger/project_triggers.tf +++ b/terraform/52-packagefeedcreatereleasetrigger/project_triggers.tf @@ -3,14 +3,18 @@ resource "octopusdeploy_external_feed_create_release_trigger" "external_feed_tri space_id = var.octopus_space_id project_id = "${octopusdeploy_project.deploy_frontend_project.id}" package { - deployment_action = octopusdeploy_deployment_process.example.step[0].run_script_action[0].name + deployment_action_slug = "hello-world-using-powershell-1" package_reference = "busybox" } package { - deployment_action = octopusdeploy_deployment_process.example.step[0].run_script_action[0].name + deployment_action_slug = "hello-world-using-powershell-1" package_reference = "nginx" } - channel_id = octopusdeploy_channel.test_channel.id + channel_id = octopusdeploy_channel.test_channel_1.id + + depends_on = [ + octopusdeploy_deployment_process.example + ] } resource "octopusdeploy_external_feed_create_release_trigger" "external_feed_trigger_2" { @@ -19,8 +23,34 @@ resource "octopusdeploy_external_feed_create_release_trigger" "external_feed_tri project_id = "${octopusdeploy_project.deploy_frontend_project.id}" is_disabled = true package { - deployment_action = octopusdeploy_deployment_process.example.step[1].run_script_action[0].name + deployment_action_slug = "hello-world-using-powershell-2" package_reference = "scratch" } - channel_id = octopusdeploy_channel.test_channel.id + channel_id = octopusdeploy_channel.test_channel_2.id + + depends_on = [ + octopusdeploy_deployment_process.example + ] +} + +resource "octopusdeploy_external_feed_create_release_trigger" "external_feed_trigger_3" { + name = "My third trigger" + space_id = var.octopus_space_id + project_id = "${octopusdeploy_project.deploy_frontend_project.id}" + is_disabled = false + package { + deployment_action_slug = "hello-world-using-powershell-1" + package_reference = "busybox" + } + primary_package { + deployment_action_slug = "helm-one" + } + primary_package { + deployment_action_slug = "helm-two" + } + channel_id = octopusdeploy_channel.test_channel_3.id + + depends_on = [ + octopusdeploy_deployment_process.example + ] } \ No newline at end of file