Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions infra/ocp/connect/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
# Validates connectivity to an existing OpenShift cluster

locals {
kubeconfig = var.kubeconfig_content != "" ? var.kubeconfig_content : yamlencode({
# Precedence: forge-injected kubeconfig (registered cluster) > manual
# var.kubeconfig_content (standalone/override) > token-based fallback.
# local.forge_kubeconfig is injected by BNK-Forge via bnk_forge_locals.tf
# whenever this workspace has a registered cluster; try() falls through
# to the next tier when forge hasn't injected it (e.g. standalone runs).
kubeconfig = try(local.forge_kubeconfig, var.kubeconfig_content != "" ? var.kubeconfig_content : yamlencode({
apiVersion = "v1"
kind = "Config"
clusters = [{ name = "ocp", cluster = {
Expand All @@ -12,7 +17,7 @@ locals {
users = [{ name = "ocp-user", user = { token = var.oc_token } }]
contexts = [{ name = "default", context = { cluster = "ocp", user = "ocp-user" } }]
current-context = "default"
})
}))
}

resource "local_file" "kubeconfig" {
Expand Down
4 changes: 2 additions & 2 deletions infra/ocp/connect/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"module": {
"name": "OpenShift Cluster Connection",
"path": "infra/ocp/connect",
"version": "1.0.0",
"version": "1.0.1",
"layer": "infrastructure",
"category": "infra",
"description": "Validates and connects to an existing OpenShift cluster",
Expand Down Expand Up @@ -43,7 +43,7 @@
{
"name": "kubeconfig_content",
"type": "string",
"description": "Kubeconfig YAML content for the OCP cluster",
"description": "Kubeconfig YAML content for the OCP cluster. Automatically superseded by the project's registered-cluster kubeconfig when one exists; only used when no registered cluster is present, e.g. standalone or manual runs.",
"default": "",
"source": "project_secret"
},
Expand Down
2 changes: 1 addition & 1 deletion infra/ocp/connect/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "api_server_url" {
}

variable "kubeconfig_content" {
description = "Kubeconfig YAML content for the OCP cluster"
description = "Kubeconfig YAML content for the OCP cluster. Automatically superseded by the project's registered-cluster kubeconfig (local.forge_kubeconfig) when one exists; this variable is only used when no registered cluster is present, e.g. standalone or manual runs."
type = string
sensitive = true
default = ""
Expand Down
Loading