Skip to content

Commit

Permalink
Merge pull request #6 from samcre/upgrade-helm-v2
Browse files Browse the repository at this point in the history
Upgrades module to Helm v2 provider
  • Loading branch information
ivankatliarchuk authored Jun 24, 2021
2 parents 2d84259 + bc8ae6f commit 4f838b5
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = false
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v4.0.1
hooks:
- id: check-added-large-files
args: ['--maxkb=500']
Expand All @@ -17,7 +17,7 @@ repos:
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.31.0
rev: v1.50.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand Down
9 changes: 9 additions & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sections:
hide: [
resources,
data-sources,
modules
]

settings:
anchor: false
7 changes: 4 additions & 3 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
config {
deep_check = false
plugin "aws" {
enabled = true
deep_check = false
ignore_module = {}
varfile = []
varfile = []
}

rule "terraform_documented_variables" {
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ module jenkins {

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| helm | >= 1.1 |
| terraform | >= 0.13 |
| helm | >= 2.0 |

## Providers

| Name | Version |
|------|---------|
| helm | >= 1.1 |
| helm | >= 2.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| app | an application to deploy | `map` | n/a | yes |
| app | an application to deploy | `map(any)` | n/a | yes |
| namespace | namespace where to deploy an application | `string` | n/a | yes |
| repository | Helm repository | `string` | n/a | yes |
| set | Value block with custom STRING values to be merged with the values yaml. | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `null` | no |
Expand All @@ -108,8 +108,9 @@ module jenkins {

## Outputs

No output.

| Name | Description |
|------|-------------|
| deployment | The state of the helm deployment |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Commands
Expand Down
39 changes: 26 additions & 13 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
resource helm_release this {
count = var.app["deploy"] ? 1 : 0
namespace = var.namespace
repository = var.repository
name = var.app["name"]
version = var.app["version"]
chart = var.app["chart"]
force_update = lookup(var.app, "force_update", true)
wait = lookup(var.app, "wait", true)
recreate_pods = lookup(var.app, "recreate_pods", true)
max_history = lookup(var.app, "max_history", 0)
lint = lookup(var.app, "lint", true)
values = var.values
resource "helm_release" "this" {
count = var.app["deploy"] ? 1 : 0
namespace = var.namespace
repository = var.repository
name = var.app["name"]
version = var.app["version"]
chart = var.app["chart"]
force_update = lookup(var.app, "force_update", true)
wait = lookup(var.app, "wait", true)
recreate_pods = lookup(var.app, "recreate_pods", true)
max_history = lookup(var.app, "max_history", 0)
lint = lookup(var.app, "lint", true)
cleanup_on_fail = lookup(var.app, "cleanup_on_fail", false)
create_namespace = lookup(var.app, "create_namespace", false)
disable_webhooks = lookup(var.app, "disable_webhooks", false)
verify = lookup(var.app, "verify", false)
reuse_values = lookup(var.app, "reuse_values", false)
reset_values = lookup(var.app, "reset_values", false)
atomic = lookup(var.app, "atomic", false)
skip_crds = lookup(var.app, "skip_crds", false)
render_subchart_notes = lookup(var.app, "render_subchart_notes", true)
disable_openapi_validation = lookup(var.app, "disable_openapi_validation", false)
wait_for_jobs = lookup(var.app, "wait_for_jobs", false)
dependency_update = lookup(var.app, "dependency_update", false)
replace = lookup(var.app, "replace", false)
values = var.values

dynamic "set" {
iterator = item
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "deployment" {
value = helm_release.this
value = var.app["deploy"] ? helm_release.this[0].metadata : []
description = "The state of the helm deployment"
}
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ variable "namespace" {

variable "app" {
description = "an application to deploy"
type = map
type = map(any)
}

variable "values" {
Expand Down
6 changes: 3 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_version = ">= 0.12"
required_version = ">= 0.13"

required_providers {
helm = ">= 1.1"
helm = ">= 2.0"
}
}
}

0 comments on commit 4f838b5

Please sign in to comment.