Minor fixes in container zipmapping
This commit is contained in:
parent
6ef8783ba3
commit
e8dcd00e87
|
@ -1,11 +1,11 @@
|
||||||
module "echo-server" {
|
module "echo-server" {
|
||||||
source = "../modules/container"
|
source = "modules/container"
|
||||||
name = "echo-server"
|
name = "echo-server"
|
||||||
image = "jmalloc/echo-server:latest"
|
image = "jmalloc/echo-server:latest"
|
||||||
|
|
||||||
web {
|
web {
|
||||||
expose = true
|
expose = "true"
|
||||||
port = 8080
|
port = 8080
|
||||||
domain = "debug.${var.domain},debug.in.${var.domain}"
|
host = "debug.${var.root-domain},debug.in.${var.root-domain}"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,10 @@ locals {
|
||||||
"traefik.protocol" = "${lookup(var.web, "protocol", "http")}"
|
"traefik.protocol" = "${lookup(var.web, "protocol", "http")}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource {
|
||||||
|
"memory" = "${lookup(var.resource, "memory", 64)}"
|
||||||
|
}
|
||||||
|
|
||||||
traefik_common_labels {
|
traefik_common_labels {
|
||||||
"traefik.enable" = "true"
|
"traefik.enable" = "true"
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ resource "docker_container" "container" {
|
||||||
user = "${var.user}"
|
user = "${var.user}"
|
||||||
networks = ["${var.networks}"]
|
networks = ["${var.networks}"]
|
||||||
|
|
||||||
# memory = "${lookup(var.resource, "memory", "64")}"
|
memory = "${local.resource["memory"]}"
|
||||||
|
|
||||||
|
|
||||||
# Look at this monstrosity
|
# Look at this monstrosity
|
||||||
# And then https://github.com/hashicorp/terraform/issues/12453#issuecomment-365569618
|
# And then https://github.com/hashicorp/terraform/issues/12453#issuecomment-365569618
|
||||||
|
@ -28,71 +27,75 @@ resource "docker_container" "container" {
|
||||||
labels = "${merge(local.default_labels,
|
labels = "${merge(local.default_labels,
|
||||||
zipmap(
|
zipmap(
|
||||||
concat(
|
concat(
|
||||||
keys(local.traefik_common_labels),
|
keys(local.default_labels),
|
||||||
split(",",
|
split("~",
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", keys(local.traefik_common_labels))
|
join("~", keys(local.traefik_common_labels))
|
||||||
)
|
)
|
||||||
),concat(
|
),
|
||||||
values(local.traefik_common_labels),
|
concat(
|
||||||
split(",",
|
values(local.default_labels),
|
||||||
|
split("~",
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", values(local.traefik_common_labels))
|
join("~", values(local.traefik_common_labels))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
zipmap(
|
||||||
|
concat(
|
||||||
|
keys(local.default_labels),
|
||||||
|
split("~",
|
||||||
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
|
"" :
|
||||||
|
join("~", keys(local.web))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
concat(
|
||||||
|
values(local.default_labels),
|
||||||
|
split("~",
|
||||||
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
|
"" :
|
||||||
|
join("~", values(local.web))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
zipmap(
|
|
||||||
concat(
|
|
||||||
keys(local.web),
|
|
||||||
split(",",
|
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
|
||||||
"" :
|
|
||||||
join(",", keys(local.web))
|
|
||||||
)
|
|
||||||
),concat(
|
|
||||||
values(local.web),
|
|
||||||
split(",",
|
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
|
||||||
"" :
|
|
||||||
join(",", values(local.web))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
zipmap(
|
zipmap(
|
||||||
concat(
|
concat(
|
||||||
keys(local.traefik_common_labels),
|
keys(local.default_labels),
|
||||||
split(",",
|
split("~",
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", keys(local.traefik_common_labels))
|
join("~", keys(local.traefik_common_labels))
|
||||||
)
|
)
|
||||||
),concat(
|
),
|
||||||
values(local.traefik_common_labels),
|
concat(
|
||||||
split(",",
|
values(local.default_labels),
|
||||||
|
split("~",
|
||||||
lookup(var.web, "expose", "false") == "false" ?
|
lookup(var.web, "expose", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", values(local.traefik_common_labels))
|
join("~", values(local.traefik_common_labels))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
zipmap(
|
zipmap(
|
||||||
concat(
|
concat(
|
||||||
keys(local.traefik_auth_labels),
|
keys(local.default_labels),
|
||||||
split(",",
|
split("~",
|
||||||
lookup(var.web, "auth", "false") == "false" ?
|
lookup(var.web, "auth", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", keys(local.traefik_auth_labels))
|
join("~", keys(local.traefik_auth_labels))
|
||||||
)
|
)
|
||||||
),concat(
|
),
|
||||||
values(local.traefik_auth_labels),
|
concat(
|
||||||
split(",",
|
values(local.default_labels),
|
||||||
|
split("~",
|
||||||
lookup(var.web, "auth", "false") == "false" ?
|
lookup(var.web, "auth", "false") == "false" ?
|
||||||
"" :
|
"" :
|
||||||
join(",", values(local.traefik_auth_labels))
|
join("~", values(local.traefik_auth_labels))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -68,8 +68,8 @@ variable "web" {
|
||||||
description = "Web Configuration"
|
description = "Web Configuration"
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
expose = "false"
|
expose = "false"
|
||||||
basicauth = "false"
|
auth = "false"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,5 @@ variable "auth_header" {
|
||||||
variable "resource" {
|
variable "resource" {
|
||||||
description = "Resource usage for the container"
|
description = "Resource usage for the container"
|
||||||
|
|
||||||
default = {
|
default = {}
|
||||||
memory = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ module "requestbin" {
|
||||||
// Default is port 80
|
// Default is port 80
|
||||||
web {
|
web {
|
||||||
expose = true
|
expose = true
|
||||||
|
port = "8000"
|
||||||
host = "requestbin.${var.root-domain}"
|
host = "requestbin.${var.root-domain}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue