Skip to content

Commit

Permalink
git repo to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
IbraheemAlSaady committed Jul 21, 2021
1 parent 3346cc2 commit f06f43d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion TERRAFORM.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ No Modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| argocd\_git\_repo\_url | The ArgoCD git config | `string` | n/a | yes |
| argocd\_additional\_applications | Additional applications to be added to ArgoCD | `list(any)` | `[]` | no |
| argocd\_additional\_projects | Additional projeccts to be added to ArgoCD | `list(any)` | `[]` | no |
| argocd\_chart\_value\_files | A list of values.yaml files to be added to the argo installation. | `list(string)` | `[]` | no |
| argocd\_chart\_values\_overrides | A map of key/value to override the argocdc chart values. The key must be the path/name of the chart value, e.g: `path.to.chart.key` | `map(string)` | `{}` | no |
| argocd\_chart\_version | The ArgoCD chart version | `string` | `"3.7.1"` | no |
| argocd\_git\_repo\_url | The ArgoCD git config | `string` | `""` | no |
| argocd\_git\_ssh\_auto\_generate\_keys | A flag to auto generate keys for git SSH | `bool` | `true` | no |
| argocd\_git\_ssh\_private\_key | The keys config for argocd git repo | `string` | `""` | no |
| argocd\_image\_tag | The image tag for the ArgoCD image | `string` | `"v2.0.4"` | no |
Expand Down
17 changes: 11 additions & 6 deletions argo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ locals {
}

gitSSHSecretKey = "sshPrivateKey"

valueFiles = concat([
yamlencode(local.cluster_credentials),
yamlencode(local.argocd_config)
], var.argocd_chart_value_files)
}

data "aws_eks_cluster" "creds" {
Expand All @@ -41,10 +46,12 @@ data "aws_eks_cluster_auth" "creds" {
}

data "template_file" "git" {
count = var.argocd_git_repo_url != "" ? 1 : 0

template = file("${path.module}/templates/git-config.tmpl")
vars = {
GIT_URL = var.argocd_git_repo_url
SECRET_NAME = kubernetes_secret.git.metadata.0.name
SECRET_NAME = kubernetes_secret.git.0.metadata.0.name
SECRET_KEY = local.gitSSHSecretKey
}
}
Expand All @@ -57,6 +64,8 @@ resource "tls_private_key" "git" {
}

resource "kubernetes_secret" "git" {
count = var.argocd_git_repo_url != "" ? 1 : 0

metadata {
name = "argocd-git-ssh-credentials"
namespace = kubernetes_namespace.argo.metadata.0.name
Expand All @@ -78,11 +87,7 @@ resource "helm_release" "argo" {
chart = "argo-cd"
version = var.argocd_chart_version

values = concat([
yamlencode(local.cluster_credentials),
yamlencode(local.argocd_config),
data.template_file.git.rendered
], var.argocd_chart_value_files)
values = concat(var.argocd_git_repo_url != "" ? [data.template_file.git.0.rendered] : [], local.valueFiles)

set {
name = "global.image.tag"
Expand Down
21 changes: 21 additions & 0 deletions examples/no-git-repo/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
config_context = "minikube"
}
}

provider "kubernetes" {
config_path = "~/.kube/config"
config_context = "minikube"
}

module "argocd-bootstrap" {
# source = "kube-champ/argocd-bootstrap/k8s"
source = "../../"

remote_clusters = []

argocd_additional_applications = []
argocd_additional_projects = []
}
8 changes: 8 additions & 0 deletions examples/no-git-repo/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "argocd_git_public_key" {
value = module.argocd-bootstrap.argocd_git_public_key
}

output "argocd_password" {
sensitive = true
value = module.argocd-bootstrap.argocd_generated_admin_password
}
2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
variable "argocd_git_repo_url" {
description = "The ArgoCD git config"
type = string

default = ""
}

variable "remote_clusters" {
Expand Down

0 comments on commit f06f43d

Please sign in to comment.