Skip to content

Commit

Permalink
Feature-3533 Adding Helm3 Support (#36)
Browse files Browse the repository at this point in the history
* Removing version declaration.

* Removing version declaration.

* Removing helm repository

* Adding require annotation and labels.

* Adding tfversion file

* Updating CI

* Update .pre-commit-config.yaml

Co-authored-by: Daniel Hoherd <[email protected]>

* Update .pre-commit-config.yaml

Co-authored-by: Daniel Hoherd <[email protected]>

* Removing `terraform-install` command exec.

* Enabling TFENV_AUTO_INSTALL param

* Enabling environment variable into container.

* Update variables.tf

Co-authored-by: Daniel Hoherd <[email protected]>

Co-authored-by: Daniel Hoherd <[email protected]>
  • Loading branch information
mishah334 and danielhoherd authored Jul 27, 2022
1 parent 31f6024 commit ad36fcf
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 32 deletions.
52 changes: 40 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
---
version: 2.1

jobs:
terraform_lint:
executors:
pre-commit-executor:
docker:
- image: hashicorp/terraform:0.13.7
- image: quay.io/astronomer/ci-pre-commit:2022-06
environment:
TFENV_AUTO_INSTALL: true

workflows:
pre-commit:
jobs:
- run_pre_commit

jobs:
run_pre_commit:
executor: pre-commit-executor
steps:
- checkout
- run: terraform init
- run: terraform fmt -check=true
- run: terraform validate
- run: rm -rf .terraform
- run: terraform -v
- pre-commit-commands

workflows:
terraform_lint:
jobs:
- terraform_lint
commands:
pre-commit-commands:
description: "Execute the pre-commit"
steps:
- run:
name: Create pre-commit-cache-key.txt
command: |
cp .pre-commit-config.yaml /tmp/pre-commit-cache-key.txt
python --version --version | sed 's/^/# /' >> /tmp/pre-commit-cache-key.txt
- restore_cache:
keys:
- pre-commit-cache-{{ checksum "/tmp/pre-commit-cache-key.txt" }}
- run:
name: Install terraform-docs
command: go install github.com/terraform-docs/[email protected]
- run:
name: Install pre-commit hooks
command: pre-commit install-hooks
- save_cache:
key: pre-commit-cache-{{ checksum "/tmp/pre-commit-cache-key.txt" }}
paths:
- ~/.cache/pre-commit
- run:
name: Run pre-commit
command: |
pre-commit run --all-files --show-diff-on-failure
23 changes: 14 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
---
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.13.0
rev: v1.74.1
hooks:
- id: terraform_fmt
- id: terraform_validate_no_variables
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.1"
rev: "v2.6.2"
hooks:
- id: prettier
args: ["--print-width=135"]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.7.2.1
hooks:
- id: shellcheck
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.2.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-xml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: no-commit-to-branch
args: ["-b", "master"]
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/astronomer/pre-commit-hooks
rev: bd325c947efcba13c03b4f4c93d882f2f83ed6ff
Expand Down
1 change: 1 addition & 0 deletions .terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2.5
7 changes: 1 addition & 6 deletions astronomer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,5 @@ resource "helm_release" "astronomer_local" {
chart = var.astronomer_chart_git_repository == "" ? var.astronomer_helm_chart_name : "/tmp/astronomer-${var.astronomer_version_git_checkout}-${random_id.collision_avoidance.hex}/astronomer"

# These settings only are applied when using a Helm chart repo
repository = var.astronomer_chart_git_repository == "" ? data.helm_repository.astronomer_repo.name : null
}

data "helm_repository" "astronomer_repo" {
url = var.astronomer_helm_chart_repo_url
name = var.astronomer_helm_chart_repo
repository = var.astronomer_chart_git_repository == "" ? var.astronomer_helm_chart_repo_url : null
}
21 changes: 21 additions & 0 deletions secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ resource "kubernetes_secret" "astronomer_bootstrap" {
metadata {
name = "astronomer-bootstrap"
namespace = var.astronomer_namespace
labels = {
"app.kubernetes.io/managed-by" = "Helm"
}
annotations = {
"meta.helm.sh/release-name" = "astronomer"
"meta.helm.sh/release-namespace" = "astronomer"
}
}

type = "kubernetes.io/generic"
Expand All @@ -21,6 +28,13 @@ resource "kubernetes_secret" "astronomer_tls" {
metadata {
name = "astronomer-tls"
namespace = var.astronomer_namespace
labels = {
"app.kubernetes.io/managed-by" = "Helm"
}
annotations = {
"meta.helm.sh/release-name" = "astronomer"
"meta.helm.sh/release-namespace" = "astronomer"
}
}

type = "kubernetes.io/tls"
Expand All @@ -38,6 +52,13 @@ resource "kubernetes_secret" "astronomer-gcs-keyfile" {
metadata {
name = "astronomer-gcs-keyfile"
namespace = var.astronomer_namespace
labels = {
"app.kubernetes.io/managed-by" = "Helm"
}
annotations = {
"meta.helm.sh/release-name" = "astronomer"
"meta.helm.sh/release-namespace" = "astronomer"
}
}

type = "kubernetes.io/generic"
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ variable "tls_key" {
}

variable "astronomer_version_git_checkout" {
description = "Verison of the helm chart to use, when using git clone method. This should exactly match what you would want to use with 'git checkout <this variable>'. This is ignored if astronomer_chart_git_repository is not configured."
description = "Version of the helm chart to use, when using git clone method. This should exactly match what you would want to use with 'git checkout <this variable>'. This is ignored if astronomer_chart_git_repository is not configured."
default = "master"
type = string
}
Expand All @@ -28,8 +28,8 @@ variable "astronomer_chart_git_repository" {
}

variable "astronomer_version" {
description = "Verison of Helm chart to use, do not include a 'v' at the front"
default = "0.12.0-alpha.1"
description = "Version of Helm chart to use, do not include a 'v' at the front"
default = "0.29.2"
type = string
}

Expand Down
3 changes: 1 addition & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ terraform {
required_version = ">= 0.13"
required_providers {
helm = {
source = "hashicorp/helm"
version = "~> 0.10"
source = "hashicorp/helm"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down

0 comments on commit ad36fcf

Please sign in to comment.