Skip to content

Commit

Permalink
add new funtions
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-mher committed Jan 19, 2024
1 parent ccceb11 commit c6dae6c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
35 changes: 35 additions & 0 deletions local_environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,38 @@ resource "local_file" "env_file" {
depends_on = [resource.null_resource.clone_repo]

}

data "template_file" "supervisor" {
template = file(var.supervisor_template_path)

vars = {
service_name = var.service_name
service_repo = var.service_repo
}
}

resource "local_file" "supervisor_file" {
count = var.supervisor_file != null ? ((anytrue([for suffix in var.valid_suffixes_supervisor : endswith(var.proxy_pass, suffix)])) != true ? 1 : 0) : 0
content = data.template_file.supervisor.rendered
filename = var.supervisor_file
depends_on = [resource.null_resource.clone_repo]

}
data "template_file" "nginx" {
template = file(var.nginx_template_path)

vars = {
service_name = var.service_name
server_host = var.server_host
proxy_pass = var.proxy_pass
proxy_header = anytrue([for suffix in var.valid_suffixes_supervisor : endswith(var.proxy_pass, suffix)]) == true ? var.proxy_pass : "$host"
}
}

resource "local_file" "nginx_file" {
count = endswith(var.nginx_template_path, "none") != true ? ((anytrue([for suffix in var.valid_suffixes_supervisor : endswith(var.server_host, suffix)])) != true ? 1 : 0) : 0
content = data.template_file.nginx.rendered
filename = var.nginx_file
depends_on = [resource.null_resource.clone_repo]

}
47 changes: 46 additions & 1 deletion local_environment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ variable "env_file" {
type = string
default = null
}
variable "supervisor_template_path" {
description = "supervisor template path"
type = string
default = "templates/supervisord/supervisord.ini"
}
variable "supervisor_file" {
description = "supervisor template path"
type = string
default = null
}
variable "nginx_template_path" {
description = "nginx template path"
type = string
default = null
}
variable "nginx_file" {
description = "nginx template path"
type = string
default = null
}
variable "microservice_catalog_path" {
description = "Microservice Catalog Folder Path"
type = string
Expand All @@ -33,7 +53,32 @@ variable "github_base" {
default = "git@github.com:ucraft-com"
}
variable "username" {
description = "A map of variables to pass to the template"
description = "A string of variables to pass to the template"
type = string
default = null
}
variable "service_name" {
description = "A string of variables to pass to the template"
type = string
default = null
}
variable "server_host" {
description = "A string of variables to pass to the template"
type = string
default = "remote"
}
variable "proxy_pass" {
description = "A string of variables to pass to the template"
type = string
default = ""
}
variable "proxy_header" {
description = "A string of variables to pass to the template"
type = string
default = ""
}
variable "valid_suffixes_supervisor" {
description = "List of valid suffixes for server_host"
type = list(string)
default = [".ucraft.ai", "ucraft.ai/"]
}

0 comments on commit c6dae6c

Please sign in to comment.