Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add variables to set AppProject, labels and destination cluster #22

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ The following providers are used by this module:

- [[provider_null]] <<provider_null,null>> (>= 3)

- [[provider_argocd]] <<provider_argocd,argocd>> (>= 5)

- [[provider_utils]] <<provider_utils,utils>> (>= 1)

- [[provider_aws]] <<provider_aws,aws>>

- [[provider_argocd]] <<provider_argocd,argocd>> (>= 5)

=== Modules

The following Modules are called:
Expand Down Expand Up @@ -182,13 +182,37 @@ Type: `string`

Default: `"cluster"`

==== [[input_argocd_project]] <<input_argocd_project,argocd_project>>

Description: Name of the Argo CD AppProject where the Application should be created. If not set, the Application will be created in a new AppProject only for this Application.

Type: `string`

Default: `null`

==== [[input_argocd_labels]] <<input_argocd_labels,argocd_labels>>

Description: Labels to attach to the Argo CD Application resource.

Type: `map(string)`

Default: `{}`

==== [[input_destination_cluster]] <<input_destination_cluster,destination_cluster>>

Description: Destination cluster where the application should be deployed.

Type: `string`

Default: `"in-cluster"`

==== [[input_target_revision]] <<input_target_revision,target_revision>>

Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.0.0"`
Default: `"v2.2.0"`

==== [[input_helm_values]] <<input_helm_values,helm_values>>

Expand Down Expand Up @@ -328,10 +352,28 @@ Description: ID to pass other modules in order to refer to this module as a depe
|n/a
|yes

|[[input_argocd_project]] <<input_argocd_project,argocd_project>>
|Name of the Argo CD AppProject where the Application should be created. If not set, the Application will be created in a new AppProject only for this Application.
|`string`
|`null`
|no

|[[input_argocd_labels]] <<input_argocd_labels,argocd_labels>>
|Labels to attach to the Argo CD Application resource.
|`map(string)`
|`{}`
|no

|[[input_destination_cluster]] <<input_destination_cluster,destination_cluster>>
|Destination cluster where the application should be deployed.
|`string`
|`"in-cluster"`
|no

|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.0.0"`
|`"v2.2.0"`
|no

|[[input_helm_values]] <<input_helm_values,helm_values>>
Expand Down
18 changes: 12 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ resource "null_resource" "dependencies" {
}

resource "argocd_project" "this" {
count = var.argocd_project == null ? 1 : 0

metadata {
name = "efs-csi-driver"
name = var.destination_cluster != "in-cluster" ? "efs-csi-driver-${var.destination_cluster}" : "efs-csi-driver"
namespace = var.argocd_namespace
annotations = {
"devops-stack.io/argocd_namespace" = var.argocd_namespace
}
}

spec {
description = "EFS CSI driver application project"
description = "EFS CSI driver application project for cluster ${var.destination_cluster}"
source_repos = ["https://github.com/camptocamp/devops-stack-module-efs-csi-driver.git"]

destination {
name = "in-cluster"
name = var.destination_cluster
namespace = "kube-system"
}

Expand Down Expand Up @@ -94,8 +96,12 @@ module "iam_assumable_role_efs" {

resource "argocd_application" "this" {
metadata {
name = "efs-csi-driver"
name = var.destination_cluster != "in-cluster" ? "efs-csi-driver-${var.destination_cluster}" : "efs-csi-driver"
namespace = var.argocd_namespace
labels = merge({
"application" = "efs-csi-driver"
"cluster" = var.destination_cluster
}, var.argocd_labels)
}

timeouts {
Expand All @@ -106,7 +112,7 @@ resource "argocd_application" "this" {
wait = var.app_autosync == { "allow_empty" = tobool(null), "prune" = tobool(null), "self_heal" = tobool(null) } ? false : true

spec {
project = argocd_project.this.metadata.0.name
project = var.argocd_project == null ? argocd_project.this[0].metadata.0.name : var.argocd_project

source {
repo_url = "https://github.com/camptocamp/devops-stack-module-efs-csi-driver.git"
Expand All @@ -118,7 +124,7 @@ resource "argocd_application" "this" {
}

destination {
name = "in-cluster"
name = var.destination_cluster
namespace = "kube-system"
}

Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ variable "argocd_namespace" {
type = string
}

variable "argocd_project" {
description = "Name of the Argo CD AppProject where the Application should be created. If not set, the Application will be created in a new AppProject only for this Application."
type = string
default = null
}

variable "argocd_labels" {
description = "Labels to attach to the Argo CD Application resource."
type = map(string)
default = {}
}

variable "destination_cluster" {
description = "Destination cluster where the application should be deployed."
type = string
default = "in-cluster"
}

variable "target_revision" {
description = "Override of target revision of the application chart."
type = string
Expand Down