Skip to content

Commit

Permalink
refactor(inputs): use cluster_domain instead of name
Browse files Browse the repository at this point in the history
The use of `cluster_domain` is clearer than just` name`, which could be interpreted as something
else.

BREAKING CHANGE: Deprecation of `name` variable

fix #53
  • Loading branch information
xunleii committed Jun 23, 2021
1 parent 286991f commit 383fe5b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion agent_nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ locals {
)))

immutable_fields_hash = sha1(join("", concat(
[var.name],
[var.cluster_domain],
var.global_flags,
try(agent.flags, []),
)))
Expand Down
6 changes: 3 additions & 3 deletions examples/hcloud-k3s/k3s.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module "k3s" {
source = "./../.."

depends_on_ = hcloud_server.agents
k3s_version = "latest"
name = "cluster.local"
depends_on_ = hcloud_server.agents
k3s_version = "latest"
cluster_domain = "cluster.local"
cidr = {
pods = "10.42.0.0/16"
services = "10.43.0.0/16"
Expand Down
8 changes: 4 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ output "kube_config" {
certificate-authority-data = base64encode(local.cluster_ca_certificate)
server = "https://${local.root_server_connection.host}:6443"
}
name = var.name
name = var.cluster_domain
}]
contexts = [{
context = {
cluster = var.name
cluster = var.cluster_domain
user : "master-user"
}
name = var.name
name = var.cluster_domain
}]
current-context = var.name
current-context = var.cluster_domain
kind = "Config"
preferences = {}
users = [{
Expand Down
4 changes: 2 additions & 2 deletions server_nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ locals {
[
"--node-ip ${server.ip}",
"--node-name '${try(server.name, key)}'",
"--cluster-domain '${var.name}'",
"--cluster-domain '${var.cluster_domain}'",
"--cluster-cidr ${var.cidr.pods}",
"--service-cidr ${var.cidr.services}",
"--token ${random_password.k3s_cluster_secret.result}",
Expand All @@ -100,7 +100,7 @@ locals {
)))

immutable_fields_hash = sha1(join("", concat(
[var.name, var.cidr.pods, var.cidr.services],
[var.cluster_domain, var.cidr.pods, var.cidr.services],
var.global_flags,
try(server.flags, []),
)))
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ variable "k3s_version" {
}

variable "name" {
description = "K3s cluster domain name (see https://rancher.com/docs/k3s/latest/en/installation/install-options/). This input is deprecated and will be remove in the next major release. Use `cluster_domain` instead."
type = string
default = "!!!DEPRECATED!!!"

validation {
condition = var.name == "!!!DEPRECATED!!!"
error_message = "Variable `name` is deprecated, use `cluster_domain` instead. It will be removed at the next major release."
}
}

variable "cluster_domain" {
description = "K3s cluster domain name (see https://rancher.com/docs/k3s/latest/en/installation/install-options/)."
type = string
default = "cluster.local"
Expand Down

0 comments on commit 383fe5b

Please sign in to comment.