From 452326c423f6f934402d90fb918e4e8f350f3f7e Mon Sep 17 00:00:00 2001 From: Shivam Negi Date: Mon, 5 Jun 2023 13:28:09 +0530 Subject: [PATCH] fix: [CDS-69453]: Updated the example (#566) * fix: [CDS-69453]: Updated the example * fix: [CDS-69453]: Updated the example * fix: [CDS-69453]: Updated the example --- .changelog/566.txt | 3 + docs/resources/platform_template.md | 231 ++++++++++++++++++ .../harness_platform_template/resource.tf | 231 ++++++++++++++++++ 3 files changed, 465 insertions(+) create mode 100644 .changelog/566.txt diff --git a/.changelog/566.txt b/.changelog/566.txt new file mode 100644 index 000000000..b526d77dc --- /dev/null +++ b/.changelog/566.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +examples/resources/harness_platform_template/ - updated the remote template example +``` \ No newline at end of file diff --git a/docs/resources/platform_template.md b/docs/resources/platform_template.md index 6cdc88863..ba88657d3 100644 --- a/docs/resources/platform_template.md +++ b/docs/resources/platform_template.md @@ -86,6 +86,80 @@ template: EOT } +## Remote Pipeline template to create new branch from existing base branch +resource "harness_platform_template" "pipeline_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Pipeline + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + stages: + - stage: + identifier: dvvdvd + name: dvvdvd + description: "" + type: Deployment + spec: + deploymentType: Kubernetes + service: + serviceRef: <+input> + serviceInputs: <+input> + environment: + environmentRef: <+input> + deployToAll: false + environmentInputs: <+input> + serviceOverrideInputs: <+input> + infrastructureDefinitions: <+input> + execution: + steps: + - step: + name: Rollout Deployment + identifier: rolloutDeployment + type: K8sRollingDeploy + timeout: 10m + spec: + skipDryRun: false + pruningEnabled: false + rollbackSteps: + - step: + name: Rollback Rollout Deployment + identifier: rollbackRolloutDeployment + type: K8sRollingRollback + timeout: 10m + spec: + pruningEnabled: false + tags: {} + failureStrategies: + - onFailure: + errors: + - AllErrors + action: + type: StageRollback + + EOT +} + ## Inline Pipeline template resource "harness_platform_template" "pipeline_template_inline" { identifier = "identifier" @@ -227,6 +301,49 @@ template: EOT } +## Remote Step template to create new branch from existing branch +resource "harness_platform_template" "step_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Step + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + timeout: 10m + type: ShellScript + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + + EOT +} + ## Inline Stage template resource "harness_platform_template" "stage_template_inline" { identifier = "identifier" @@ -349,6 +466,72 @@ template: EOT } +## Remote Stage template to create new branch from existing branch +resource "harness_platform_template" "stage_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Stage + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + type: Deployment + spec: + deploymentType: Kubernetes + service: + serviceRef: <+input> + serviceInputs: <+input> + environment: + environmentRef: <+input> + deployToAll: false + environmentInputs: <+input> + infrastructureDefinitions: <+input> + execution: + steps: + - step: + type: ShellScript + name: Shell Script_1 + identifier: ShellScript_1 + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + timeout: <+input> + rollbackSteps: [] + failureStrategies: + - onFailure: + errors: + - AllErrors + action: + type: StageRollback + + EOT +} + ## Inline StepGroup template resource "harness_platform_template" "stepgroup_template_inline" { identifier = "identifier" @@ -435,6 +618,54 @@ template: EOT } +## Remote StepGroup template to create new branch from existing branch +resource "harness_platform_template" "stepgroup_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: StepGroup + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + stageType: Deployment + steps: + - step: + type: ShellScript + name: Shell Script_1 + identifier: ShellScript_1 + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + timeout: 10m + + EOT +} + ## Inline Monitered Service template resource "harness_platform_template" "monitered_service_template_inline" { identifier = "identifier" diff --git a/examples/resources/harness_platform_template/resource.tf b/examples/resources/harness_platform_template/resource.tf index f85f2c4a4..0c10562be 100644 --- a/examples/resources/harness_platform_template/resource.tf +++ b/examples/resources/harness_platform_template/resource.tf @@ -71,6 +71,80 @@ template: EOT } +## Remote Pipeline template to create new branch from existing base branch +resource "harness_platform_template" "pipeline_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Pipeline + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + stages: + - stage: + identifier: dvvdvd + name: dvvdvd + description: "" + type: Deployment + spec: + deploymentType: Kubernetes + service: + serviceRef: <+input> + serviceInputs: <+input> + environment: + environmentRef: <+input> + deployToAll: false + environmentInputs: <+input> + serviceOverrideInputs: <+input> + infrastructureDefinitions: <+input> + execution: + steps: + - step: + name: Rollout Deployment + identifier: rolloutDeployment + type: K8sRollingDeploy + timeout: 10m + spec: + skipDryRun: false + pruningEnabled: false + rollbackSteps: + - step: + name: Rollback Rollout Deployment + identifier: rollbackRolloutDeployment + type: K8sRollingRollback + timeout: 10m + spec: + pruningEnabled: false + tags: {} + failureStrategies: + - onFailure: + errors: + - AllErrors + action: + type: StageRollback + + EOT +} + ## Inline Pipeline template resource "harness_platform_template" "pipeline_template_inline" { identifier = "identifier" @@ -212,6 +286,49 @@ template: EOT } +## Remote Step template to create new branch from existing branch +resource "harness_platform_template" "step_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Step + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + timeout: 10m + type: ShellScript + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + + EOT +} + ## Inline Stage template resource "harness_platform_template" "stage_template_inline" { identifier = "identifier" @@ -334,6 +451,72 @@ template: EOT } +## Remote Stage template to create new branch from existing branch +resource "harness_platform_template" "stage_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: Stage + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + type: Deployment + spec: + deploymentType: Kubernetes + service: + serviceRef: <+input> + serviceInputs: <+input> + environment: + environmentRef: <+input> + deployToAll: false + environmentInputs: <+input> + infrastructureDefinitions: <+input> + execution: + steps: + - step: + type: ShellScript + name: Shell Script_1 + identifier: ShellScript_1 + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + timeout: <+input> + rollbackSteps: [] + failureStrategies: + - onFailure: + errors: + - AllErrors + action: + type: StageRollback + + EOT +} + ## Inline StepGroup template resource "harness_platform_template" "stepgroup_template_inline" { identifier = "identifier" @@ -420,6 +603,54 @@ template: EOT } +## Remote StepGroup template to create new branch from existing branch +resource "harness_platform_template" "stepgroup_template_remote" { + identifier = "identifier" + org_id = harness_platform_project.test.org_id + project_id = harness_platform_project.test.id + name = "name" + comments = "comments" + version = "ab" + is_stable = true + git_details { + branch_name = "new_branch" + commit_message = "Commit" + file_path = "file_path" + connector_ref = "account.connector_ref" + store_type = "REMOTE" + repo_name = "repo_name" + base_branch = "main" + } + template_yaml = <<-EOT +template: + name: "name" + identifier: "identifier" + versionLabel: "ab" + type: StepGroup + projectIdentifier: ${harness_platform_project.test.id} + orgIdentifier: ${harness_platform_project.test.org_id} + tags: {} + spec: + stageType: Deployment + steps: + - step: + type: ShellScript + name: Shell Script_1 + identifier: ShellScript_1 + spec: + shell: Bash + onDelegate: true + source: + type: Inline + spec: + script: <+input> + environmentVariables: [] + outputVariables: [] + timeout: 10m + + EOT +} + ## Inline Monitered Service template resource "harness_platform_template" "monitered_service_template_inline" { identifier = "identifier"