-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from fuchicorp/feature/69
Deprecate listed tools from common tools (terraform-helm-chart)
- Loading branch information
Showing
3 changed files
with
57 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,61 @@ | ||
locals { | ||
required_values = { | ||
## Deployment endpoint for ingress | ||
# Deployment endpoint for ingress | ||
deployment_endpoint = "${lower(var.deployment_endpoint)}" | ||
|
||
## <deployment_name> for backend.tf and also release name | ||
deployment_name = "${lower(var.deployment_name)}" | ||
|
||
## <env_vars> for global environment variables takes map() | ||
env_vars = "${trimspace(join("\n", data.template_file.env_vars.*.rendered))}" | ||
# <deployment_name> for backend.tf and also release name | ||
deployment_name = "${lower(var.deployment_name)}" | ||
# <env_vars> for global environment variables takes map() | ||
env_vars = "${trimspace(join("\n", data.template_file.env_vars.*.rendered))}" | ||
} | ||
|
||
## When all requred values all deffined then also will incloude users values | ||
# When all requred values all deffined then also will incloude users values | ||
template_all_values = "${merge(local.required_values, var.template_custom_vars)}" | ||
|
||
timeout = "${var.timeout}" | ||
recreate_pods = "${var.recreate_pods}" | ||
timeout = "${var.timeout}" | ||
recreate_pods = "${var.recreate_pods}" | ||
} | ||
|
||
## template_file.env_vars just converting to right values | ||
# template_file.env_vars just converting to right values | ||
data "template_file" "env_vars" { | ||
count = "${length(keys(var.env_vars))}" | ||
template = " $${key}: \"$${value}\"" | ||
|
||
vars { | ||
key = "${element(keys(var.env_vars), count.index)}" | ||
value = "${element(values(var.env_vars), count.index)}" | ||
} | ||
} | ||
|
||
## template_file.chart_values_template actual values.yaml file from charts | ||
# template_file.chart_values_template actual values.yaml file from charts | ||
data "template_file" "chart_values_template" { | ||
count = "${var.remote_chart == "true" ? 0 : 1 }" | ||
template = "${file("charts/${var.deployment_path}/values.yaml")}" | ||
|
||
vars = "${local.template_all_values}" | ||
count = "${var.enabled == "true" ? 1 : 0 }" | ||
template = "${file("${var.deployment_path}/values.yaml")}" | ||
vars = "${local.template_all_values}" | ||
} | ||
|
||
## This resource was disabled and moved to output please see the ticket | ||
## https://github.com/fuchicorp/terraform-helm-chart/issues/21 | ||
# This resource was disabled and moved to output please see the ticket | ||
# https://github.com/fuchicorp/terraform-helm-chart/issues/21 | ||
# resource "local_file" "deployment_values" { | ||
# content = "${trimspace(data.template_file.chart_values_template.rendered)}" | ||
# content = "${trimspace(data.template_file.chart_values_template.0.rendered)}" | ||
# filename = "${path.module}/${var.deployment_name}-values.yaml" | ||
# } | ||
|
||
output "deployment_values" { | ||
value = "${data.template_file.chart_values_template.0.rendered}" | ||
value = "${data.template_file.chart_values_template.*.rendered}" | ||
description = "This output is for storing values.yaml" | ||
} | ||
|
||
locals { | ||
trigger = "${var.trigger == "UUID" ? uuid() : var.trigger}" | ||
} | ||
|
||
## helm_release.helm_deployment is actual helm deployment | ||
# helm_release.helm_deployment is actual helm deployment | ||
resource "helm_release" "helm_deployment" { | ||
count = "${var.remote_chart == "true" ? 0 : 1 }" | ||
name = "${var.deployment_name}-${var.deployment_environment}" | ||
namespace = "${var.deployment_environment}" | ||
chart = "./charts/${var.deployment_path}" | ||
timeout = "${local.timeout}" | ||
recreate_pods = "${local.recreate_pods}" | ||
version = "${var.release_version}" | ||
|
||
values = [ | ||
"${trimspace(data.template_file.chart_values_template.rendered)}", | ||
] | ||
} | ||
|
||
## helm_release.helm_deployment is actual helm deployment | ||
resource "helm_release" "helm_remote_deployment" { | ||
count = "${var.remote_chart == "true" ? 1 : 0 }" | ||
count = "${var.enabled == "true" ? 1 : 0}" | ||
name = "${var.deployment_name}-${var.deployment_environment}" | ||
namespace = "${var.deployment_environment}" | ||
chart = "${var.deployment_path}" | ||
timeout = "${local.timeout}" | ||
recreate_pods = "${local.recreate_pods}" | ||
version = "${var.release_version}" | ||
values = [ | ||
"${file("${var.values}")}" | ||
values = [ | ||
"${trimspace(data.template_file.chart_values_template.rendered)}", | ||
] | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,55 @@ | ||
## The name of the deployment | ||
# The name of the deployment | ||
variable "deployment_name" { | ||
description = "The name of the deployment" | ||
} | ||
|
||
## The name of the environment | ||
# The name of the environment | ||
variable "deployment_environment" { | ||
description = "The name of the environment" | ||
} | ||
|
||
## Chart location or chart name | ||
# Chart location or chart name | ||
variable "deployment_path" { | ||
description = "Chart location or chart name <stable/example>" | ||
} | ||
|
||
## Endpoint for the application | ||
# Endpoint for the application | ||
variable "deployment_endpoint" { | ||
description = "Endpoint for the application" | ||
} | ||
|
||
variable "template_custom_vars" { | ||
type = "map" | ||
default = {} | ||
type = "map" | ||
default = {} | ||
} | ||
|
||
variable "env_vars" { | ||
type = "map" | ||
default = {} | ||
type = "map" | ||
default = {} | ||
} | ||
|
||
variable "trigger" { | ||
default = "UUID" | ||
default = "UUID" | ||
} | ||
|
||
variable "timeout" { | ||
default = "400" | ||
default = "400" | ||
} | ||
|
||
variable "recreate_pods" { | ||
default = false | ||
default = false | ||
} | ||
variable "release_version" { | ||
description = "(Required) Specify the exact chart version to install" | ||
default = " 0.1.0" | ||
|
||
} | ||
|
||
variable "release_version" { | ||
description = "(Required) Specify the exact chart version to install" | ||
default = " 0.1.0" | ||
|
||
} | ||
|
||
variable "enabled" { | ||
default = "true" | ||
} | ||
|
||
variable "remote_chart" { | ||
default = "false" | ||
} | ||
|
||
variable "values" { | ||
default = "values.yaml" | ||
} | ||
|
||
default = "values.yaml" | ||
} |