Skip to content

Commit

Permalink
Terraform changes for ImportFromGit feature (#682)
Browse files Browse the repository at this point in the history
* Terraform changes for ImportFromGit feature

* Template Terraform changes

* changes

* testing complete

* changelog

* go-client version update

* go.mod

* changes

* changes

* changes-3

* resource.tf

* go generate

* changes

* changes

* changes
  • Loading branch information
vtxorxwitty committed Sep 12, 2023
1 parent ce46bc5 commit ae7270e
Show file tree
Hide file tree
Showing 11 changed files with 783 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .changelog/682.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
harness_platform_template - Added support to import Template entity from git.
harness_platform_input_set - Added support to import InputSet entity from git.
```
46 changes: 45 additions & 1 deletion docs/resources/platform_input_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ inputSet:
value: "value"
EOT
}
# Importing Input Set from Git
resource "harness_platform_input_set" "test" {
identifier = "inputset"
org_id = "default"
project_id = "V"
name = "inputset"
pipeline_id = "DoNotDeletePipeline"
import_from_git = true
git_import_info {
branch_name = "main"
file_path = ".harness/inputset.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
input_set_import_request {
input_set_name = "inputset"
input_set_description = ""
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -85,13 +105,16 @@ EOT
- `org_id` (String) Unique identifier of the organization.
- `pipeline_id` (String) Identifier of the pipeline
- `project_id` (String) Unique identifier of the project.
- `yaml` (String) Input Set YAML. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId.

### Optional

- `description` (String) Description of the resource.
- `git_details` (Block List, Max: 1) Contains parameters related to creating an Entity for Git Experience. (see [below for nested schema](#nestedblock--git_details))
- `git_import_info` (Block List, Max: 1) Contains Git Information for importing entities from Git (see [below for nested schema](#nestedblock--git_import_info))
- `import_from_git` (Boolean) Flag to set if importing from Git
- `input_set_import_request` (Block List, Max: 1) Contains parameters for importing a input set (see [below for nested schema](#nestedblock--input_set_import_request))
- `tags` (Set of String) Tags to associate with the resource.
- `yaml` (String) Input Set YAML. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId.

### Read-Only

Expand All @@ -114,6 +137,27 @@ Optional:
- `repo_name` (String) Name of the repository.
- `store_type` (String) Specifies whether the Entity is to be stored in Git or not. Possible values: INLINE, REMOTE.


<a id="nestedblock--git_import_info"></a>
### Nested Schema for `git_import_info`

Optional:

- `branch_name` (String) Name of the branch.
- `connector_ref` (String) Identifier of the Harness Connector used for importing entity from Git To reference a connector at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference a connector at the account scope, prefix 'account` to the expression: account.{identifier}.
- `file_path` (String) File path of the Entity in the repository.
- `is_force_import` (Boolean)
- `repo_name` (String) Name of the repository.


<a id="nestedblock--input_set_import_request"></a>
### Nested Schema for `input_set_import_request`

Optional:

- `input_set_description` (String) Description of the input set.
- `input_set_name` (String) Name of the input set.

## Import

Import is supported using the following syntax:
Expand Down
88 changes: 88 additions & 0 deletions docs/resources/platform_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,69 @@ resource "time_sleep" "wait_10_seconds" {
depends_on = [harness_platform_template.test2]
destroy_duration = "10s"
}
##Importing Account Level Templates
resource "harness_platform_template" "test" {
identifier = "accounttemplate"
name = "accounttemplate"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/accounttemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "accounttemplate"
template_version = "v2"
template_description = ""
}
}
##Importing Org Level Templates
resource "harness_platform_template" "test" {
identifier = "orgtemplate"
name = "orgtemplate"
org_id = "org"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/orgtemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "orgtemplate"
template_version = "v2"
template_description = ""
}
}
##Importing Project Level Templates
resource "harness_platform_template" "test" {
identifier = "projecttemplate"
name = "projecttemplate"
org_id = "org"
project_id = "project"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/projecttemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "projecttemplate"
template_version = "v2"
template_description = ""
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -1115,10 +1178,13 @@ resource "time_sleep" "wait_10_seconds" {
- `description` (String, Deprecated) Description of the entity. Description field is deprecated
- `force_delete` (String) Enable this flag for force deletion of template. It will delete the Harness entity even if your pipelines or other entities reference it
- `git_details` (Block List, Max: 1) Contains parameters related to creating an Entity for Git Experience. (see [below for nested schema](#nestedblock--git_details))
- `git_import_details` (Block List, Max: 1) Contains Git Information for importing entities from Git (see [below for nested schema](#nestedblock--git_import_details))
- `import_from_git` (Boolean) Flag to set if importing from Git
- `is_stable` (Boolean) True if given version for template to be set as stable.
- `org_id` (String) Organization Identifier for the Entity
- `project_id` (String) Project Identifier for the Entity
- `tags` (Set of String) Tags to associate with the resource.
- `template_import_request` (Block List, Max: 1) Contains parameters for importing template. (see [below for nested schema](#nestedblock--template_import_request))
- `template_yaml` (String) Yaml for creating new Template. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId.

### Read-Only
Expand All @@ -1140,6 +1206,28 @@ Optional:
- `repo_name` (String) Name of the repository.
- `store_type` (String) Specifies whether the Entity is to be stored in Git or not. Possible values: INLINE, REMOTE.


<a id="nestedblock--git_import_details"></a>
### Nested Schema for `git_import_details`

Optional:

- `branch_name` (String) Name of the branch.
- `connector_ref` (String) Identifier of the Harness Connector used for importing entity from Git To reference a connector at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference a connector at the account scope, prefix 'account` to the expression: account.{identifier}.
- `file_path` (String) File path of the Entity in the repository.
- `is_force_import` (Boolean)
- `repo_name` (String) Name of the repository.


<a id="nestedblock--template_import_request"></a>
### Nested Schema for `template_import_request`

Optional:

- `template_description` (String) Description of the template.
- `template_name` (String) Name of the template.
- `template_version` (String) Version of the template.

## Import

Import is supported using the following syntax:
Expand Down
20 changes: 20 additions & 0 deletions examples/resources/harness_platform_input_set/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,23 @@ inputSet:
value: "value"
EOT
}

# Importing Input Set from Git
resource "harness_platform_input_set" "test" {
identifier = "inputset"
org_id = "default"
project_id = "V"
name = "inputset"
pipeline_id = "DoNotDeletePipeline"
import_from_git = true
git_import_info {
branch_name = "main"
file_path = ".harness/inputset.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
input_set_import_request {
input_set_name = "inputset"
input_set_description = ""
}
}
63 changes: 63 additions & 0 deletions examples/resources/harness_platform_template/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1082,4 +1082,67 @@ resource "harness_platform_template" "template_v1" {
resource "time_sleep" "wait_10_seconds" {
depends_on = [harness_platform_template.test2]
destroy_duration = "10s"
}

##Importing Account Level Templates
resource "harness_platform_template" "test" {
identifier = "accounttemplate"
name = "accounttemplate"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/accounttemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "accounttemplate"
template_version = "v2"
template_description = ""
}
}

##Importing Org Level Templates
resource "harness_platform_template" "test" {
identifier = "orgtemplate"
name = "orgtemplate"
org_id = "org"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/orgtemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "orgtemplate"
template_version = "v2"
template_description = ""
}
}

##Importing Project Level Templates
resource "harness_platform_template" "test" {
identifier = "projecttemplate"
name = "projecttemplate"
org_id = "org"
project_id = "project"
version = "v2"
is_stable = false
import_from_git = true
git_import_details {
branch_name = "main"
file_path = ".harness/projecttemplate.yaml"
connector_ref = "account.DoNotDeleteGithub"
repo_name = "open-repo"
}
template_import_request {
template_name = "projecttemplate"
template_version = "v2"
template_description = ""
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/antihax/optional v1.0.0
github.com/docker/docker v24.0.5+incompatible
github.com/harness/harness-go-sdk v0.3.49
github.com/harness/harness-openapi-go-client v0.0.18
github.com/harness/harness-openapi-go-client v0.0.19
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
Expand Down Expand Up @@ -99,4 +99,4 @@ require (

//replace github.com/harness/harness-go-sdk => ../harness-go-sdk

// replace github.com/harness/harness-openapi-go-client => ../harness-openapi-go-client
// replace github.com/harness/harness-openapi-go-client => ../harness-openapi-go-client
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ github.com/harness/harness-go-sdk v0.3.48 h1:j/c52s/GwABtoetw35MfzEDqWZO85lZgdB+
github.com/harness/harness-go-sdk v0.3.48/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.49 h1:wtgo8/GEMjEjXyhfliKl1qlNqOGrnLpq8gdRghY1G9M=
github.com/harness/harness-go-sdk v0.3.49/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-openapi-go-client v0.0.18 h1:gPhLOSOwjmZJ3aLjJiBbWPOMSBm8h72wbVSfx19eWZM=
github.com/harness/harness-openapi-go-client v0.0.18/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/harness/harness-openapi-go-client v0.0.19 h1:8XuZvSPZrNqKRLh7Qksdz78WvRMRzRf88LgzxoT5u7k=
github.com/harness/harness-openapi-go-client v0.0.19/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
Loading

0 comments on commit ae7270e

Please sign in to comment.