Skip to content

Commit

Permalink
feat: [CDS-98026]: TF support for gitops project (#1003)
Browse files Browse the repository at this point in the history
* fix: [CDS-98026]: Terraform Project resources

* fix: [CDS-98026]: Terraform Project resources

* fix: [CDS-98026]: Terraform Project resources

* fix: [CDS-98026]: Terraform Project resources

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project

* feat: [CDS-98026]: TF support for gitops project
  • Loading branch information
shivamnegi94 committed Jul 8, 2024
1 parent 39f3d68 commit 66c8d4c
Show file tree
Hide file tree
Showing 15 changed files with 1,272 additions and 7 deletions.
84 changes: 84 additions & 0 deletions docs/data-sources/platform_gitops_project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_gitops_project Data Source - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
---

# harness_platform_gitops_project (Data Source)



## Example Usage

```terraform
data "harness_platform_gitops_repository" "example" {
agent_id = "agent_id"
query_name = "query_name"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `account_id` (String) Account identifier of the GitOps project.
- `agent_id` (String) Agent identifier of the GitOps project.
- `project` (Block List, Min: 1) App projects configuration details. (see [below for nested schema](#nestedblock--project))

### Optional

- `org_id` (String) Org identifier of the GitOps project.
- `project_id` (String) Project identifier of the GitOps repository.
- `query_name` (String) Identifier for the GitOps project.
- `upsert` (Boolean) Indicates if the GitOps repository should be updated if existing and inserted if not.

### Read-Only

- `id` (String) The ID of this resource.

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

Optional:

- `metadata` (Block List) Metadata details that all persisted resources must have. (see [below for nested schema](#nestedblock--project--metadata))
- `spec` (Block List) Spec is the specification of an AppProject. (see [below for nested schema](#nestedblock--project--spec))

<a id="nestedblock--project--metadata"></a>
### Nested Schema for `project.metadata`

Optional:

- `generation` (String) A sequence number representing a specific generation of the desired state.
- `name` (String) Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically.
- `namespace` (String) The namespace where the GitOps project should be created.


<a id="nestedblock--project--spec"></a>
### Nested Schema for `project.spec`

Optional:

- `cluster_resource_whitelist` (Block List) ClusterResourceWhitelist contains list of whitelisted cluster level resources. (see [below for nested schema](#nestedblock--project--spec--cluster_resource_whitelist))
- `destinations` (Block List) Destinations contains list of destinations available for deployment. (see [below for nested schema](#nestedblock--project--spec--destinations))
- `source_repos` (List of String) SourceRepos contains list of repository URLs which can be used for deployment.

<a id="nestedblock--project--spec--cluster_resource_whitelist"></a>
### Nested Schema for `project.spec.cluster_resource_whitelist`

Optional:

- `group` (String) Cluster group name.
- `kind` (String) Cluster kind.


<a id="nestedblock--project--spec--destinations"></a>
### Nested Schema for `project.spec.destinations`

Optional:

- `namespace` (String) Namespace specifies the target namespace for the application's resources.
- `server` (String) Server specifies the URL of the target cluster and must be set to the Kubernetes control plane API.
172 changes: 172 additions & 0 deletions docs/resources/platform_gitops_project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_gitops_project Resource - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
---

# harness_platform_gitops_project (Resource)



## Example Usage

```terraform
// Create Account level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
agent_id = "agentIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}
// Create Org level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
org_id = "orgIdentifier"
agent_id = "agentIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}
// Create Project level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
org_id = "orgIdentifier"
agent_id = "agentIdentifier"
project_id = "projectIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `account_id` (String) Account identifier of the GitOps project.
- `agent_id` (String) Agent identifier of the GitOps project.
- `project` (Block List, Min: 1) App projects configuration details. (see [below for nested schema](#nestedblock--project))

### Optional

- `org_id` (String) Org identifier of the GitOps project.
- `project_id` (String) Project identifier of the GitOps repository.
- `query_name` (String) Identifier for the GitOps project.
- `upsert` (Boolean) Indicates if the GitOps repository should be updated if existing and inserted if not.

### Read-Only

- `id` (String) The ID of this resource.

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

Optional:

- `metadata` (Block List) Metadata details that all persisted resources must have. (see [below for nested schema](#nestedblock--project--metadata))
- `spec` (Block List) Spec is the specification of an AppProject. (see [below for nested schema](#nestedblock--project--spec))

<a id="nestedblock--project--metadata"></a>
### Nested Schema for `project.metadata`

Optional:

- `generation` (String) A sequence number representing a specific generation of the desired state.
- `name` (String) Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically.
- `namespace` (String) The namespace where the GitOps project should be created.


<a id="nestedblock--project--spec"></a>
### Nested Schema for `project.spec`

Optional:

- `cluster_resource_whitelist` (Block List) ClusterResourceWhitelist contains list of whitelisted cluster level resources. (see [below for nested schema](#nestedblock--project--spec--cluster_resource_whitelist))
- `destinations` (Block List) Destinations contains list of destinations available for deployment. (see [below for nested schema](#nestedblock--project--spec--destinations))
- `source_repos` (List of String) SourceRepos contains list of repository URLs which can be used for deployment.

<a id="nestedblock--project--spec--cluster_resource_whitelist"></a>
### Nested Schema for `project.spec.cluster_resource_whitelist`

Optional:

- `group` (String) Cluster group name.
- `kind` (String) Cluster kind.


<a id="nestedblock--project--spec--destinations"></a>
### Nested Schema for `project.spec.destinations`

Optional:

- `namespace` (String) Namespace specifies the target namespace for the application's resources.
- `server` (String) Server specifies the URL of the target cluster and must be set to the Kubernetes control plane API.

## Import

Import is supported using the following syntax:

```shell
# Import an Account level Gitops Repository
terraform import harness_platform_gitops_project.example <agent_id>/<query_name>

# Import an Org level Gitops Repository
terraform import harness_platform_gitops_repository.example <organization_id>/<agent_id>/<query_name

# Import a Project level Gitops Repository
terraform import harness_platform_gitops_repository.example <organization_id>/<project_id>/<agent_id>/<query_name>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "harness_platform_gitops_repository" "example" {
agent_id = "agent_id"
query_name = "query_name"
}
8 changes: 8 additions & 0 deletions examples/resources/harness_platform_gitops_project/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Import an Account level Gitops Repository
terraform import harness_platform_gitops_project.example <agent_id>/<query_name>

# Import an Org level Gitops Repository
terraform import harness_platform_gitops_repository.example <organization_id>/<agent_id>/<query_name

# Import a Project level Gitops Repository
terraform import harness_platform_gitops_repository.example <organization_id>/<project_id>/<agent_id>/<query_name>
77 changes: 77 additions & 0 deletions examples/resources/harness_platform_gitops_project/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Create Account level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
agent_id = "agentIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}

// Create Org level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
org_id = "orgIdentifier"
agent_id = "agentIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}

// Create Project level gitOps project
resource "harness_platform_gitops_project" "test" {
account_id = "accountIdentifier"
org_id = "orgIdentifier"
agent_id = "agentIdentifier"
project_id = "projectIdentifier"
upsert = true
project {
metadata {
generation = "generation"
name = "name"
namespace = "namespace"
}
spec {
cluster_resource_whitelist {
group = "*"
kind = "*"
}
destinations {
namespace = "*"
server = "*"
}
source_repos = ["*"]
}
}
}
6 changes: 3 additions & 3 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/aws/aws-sdk-go v1.46.4
github.com/docker/docker v24.0.5+incompatible
github.com/harness/harness-go-sdk v0.3.94
github.com/harness/harness-go-sdk v0.3.95
github.com/harness/harness-openapi-go-client v0.0.19
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand All @@ -27,7 +27,7 @@ require (
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.16.0 // indirect
Expand Down Expand Up @@ -87,4 +87,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
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53E
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
Expand Down Expand Up @@ -54,8 +54,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/harness/harness-go-sdk v0.3.94 h1:bipyLc6zzBFaI8Lpt1ZZHdjemDKNorU5oixQf5ZWXBU=
github.com/harness/harness-go-sdk v0.3.94/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.95 h1:L1H+ckGlNi9HEvU79NYlRBmFBv79rGS4Tz8eaeCMVyI=
github.com/harness/harness-go-sdk v0.3.95/go.mod h1:a/1HYTgVEuNEoh3Z3IsOHZdlUNxl94KcX57ZSNVGll0=
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=
Expand Down
Loading

0 comments on commit 66c8d4c

Please sign in to comment.