From aca282255b8d80477a2712d525f53f213584e343 Mon Sep 17 00:00:00 2001 From: Shashank Jain Date: Fri, 25 Oct 2024 14:03:53 +0530 Subject: [PATCH] =?UTF-8?q?[PIPE-22716]=20Fixed=20execution=20pipeline=20f?= =?UTF-8?q?ilter=20creation=20for=20service=5Fide=E2=80=A6=20(#1104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [PIPE-22716] Fixed execution pipeline filter creation for service_identifier tag * Added documentation and examples --- .changelog/1090.txt | 5 ++++ .../data-sources/platform_pipeline_filters.md | 9 ++++--- .../resource.tf | 25 ++++++++++++++++++- .../data_source_pipeline_filters.go | 9 +++++++ .../resource_pipeline_filters.go | 14 +++++++++++ 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .changelog/1090.txt diff --git a/.changelog/1090.txt b/.changelog/1090.txt new file mode 100644 index 000000000..212a3b31f --- /dev/null +++ b/.changelog/1090.txt @@ -0,0 +1,5 @@ +```release-note:fix +harness_platform_pipeline_filters: added service_identifiers to fix service level filtering for pipeline execution filters. lifecycle. + +Added example for execution pipeline filter with service_identifiers. +``` \ No newline at end of file diff --git a/docs/data-sources/platform_pipeline_filters.md b/docs/data-sources/platform_pipeline_filters.md index f0b89d48e..f8e7fa182 100644 --- a/docs/data-sources/platform_pipeline_filters.md +++ b/docs/data-sources/platform_pipeline_filters.md @@ -61,6 +61,7 @@ Read-Only: - `artifact_display_names` (Set of String) - `deployment_types` (String) - `environment_names` (Set of String) +- `service_identifiers` (Set of String) - `service_names` (Set of String) @@ -76,15 +77,15 @@ Read-Only: - `tag` (String) -### Nested Schema for `filter_properties.module_properties.ci.tag` +### Nested Schema for `filter_properties.module_properties.ci.ci_execution_info` Read-Only: - `event` (String) -- `pull_request` (List of Object) (see [below for nested schema](#nestedobjatt--filter_properties--module_properties--ci--tag--pull_request)) +- `pull_request` (List of Object) (see [below for nested schema](#nestedobjatt--filter_properties--module_properties--ci--ci_execution_info--pull_request)) - -### Nested Schema for `filter_properties.module_properties.ci.tag.pull_request` + +### Nested Schema for `filter_properties.module_properties.ci.ci_execution_info.pull_request` Read-Only: diff --git a/examples/resources/harness_platform_pipeline_filters/resource.tf b/examples/resources/harness_platform_pipeline_filters/resource.tf index 0ab78fe32..23e303eeb 100644 --- a/examples/resources/harness_platform_pipeline_filters/resource.tf +++ b/examples/resources/harness_platform_pipeline_filters/resource.tf @@ -13,6 +13,28 @@ resource "harness_platform_pipeline_filters" "test" { filter_visibility = "EveryOne" } +# pipeline execution filter consisiting services (service_identifiers) filter +resource "harness_platform_pipeline_filters" "execution" { + identifier = "identifier" + name = "name" + org_id = "org_id" + project_id = "project_id" + type = "PipelineSetup" + filter_properties { + name = "pipeline_name" + description = "pipeline_description" + pipeline_identifiers = ["id1", "id2"] + filter_type = "PipelineExecution" + module_properties { + cd { + deployment_types = "Kubernetes" + service_identifiers = ["nginx"] + } + } + } + filter_visibility = "EveryOne" +} + # pipeline filter with tags resource "harness_platform_pipeline_filters" "example_with_tags" { @@ -47,4 +69,5 @@ resource "harness_platform_pipeline_filters" "example_with_tags" { } } } -} \ No newline at end of file +} + diff --git a/internal/service/platform/pipeline_filters/data_source_pipeline_filters.go b/internal/service/platform/pipeline_filters/data_source_pipeline_filters.go index f06354813..71716aa5b 100644 --- a/internal/service/platform/pipeline_filters/data_source_pipeline_filters.go +++ b/internal/service/platform/pipeline_filters/data_source_pipeline_filters.go @@ -206,6 +206,15 @@ func DataSourcePipelineFilters() *schema.Resource { Type: schema.TypeString, }, }, + "service_identifiers": { + Description: "Service identifiers of the CD pipeline.", + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "environment_names": { Description: "Environment names of the CD pipeline.", Type: schema.TypeSet, diff --git a/internal/service/platform/pipeline_filters/resource_pipeline_filters.go b/internal/service/platform/pipeline_filters/resource_pipeline_filters.go index 7f119fe9b..e6948e4c9 100644 --- a/internal/service/platform/pipeline_filters/resource_pipeline_filters.go +++ b/internal/service/platform/pipeline_filters/resource_pipeline_filters.go @@ -203,6 +203,14 @@ func ResourcePipelineFilters() *schema.Resource { Type: schema.TypeString, }, }, + "service_identifiers": { + Description: "Service identifiers of the CD pipeline.", + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "environment_names": { Description: "Environment names of the CD pipeline.", Type: schema.TypeSet, @@ -392,6 +400,9 @@ func buildPipelineFilter(d *schema.ResourceData) *nextgen.PipelineFilter { if attr := cdProperties["service_names"].(*schema.Set).List(); len(attr) > 0 { cd["serviceNames"] = attr } + if attr := cdProperties["service_identifiers"].(*schema.Set).List(); len(attr) > 0 { + cd["serviceIdentifiers"] = attr + } if attr := cdProperties["environment_names"].(*schema.Set).List(); len(attr) > 0 { cd["environmentNames"] = attr } @@ -491,6 +502,9 @@ func readPipelineFilter(d *schema.ResourceData, filter *nextgen.PipelineFilter) if attr, ok := hCdProperties["serviceNames"]; ok { cdProperties["service_names"] = attr } + if attr, ok := hCdProperties["serviceIdentifiers"]; ok { + cdProperties["service_identifiers"] = attr + } if attr, ok := hCdProperties["environmentNames"]; ok { cdProperties["environment_names"] = attr }