Skip to content

feat: include cluster name in banner output#581

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/feature-include-cluster-name-in-output
Draft

feat: include cluster name in banner output#581
Copilot wants to merge 2 commits intomainfrom
copilot/feature-include-cluster-name-in-output

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

When running kor against multiple clusters with a shared Slack webhook, scan output lacks cluster identity, making it hard to correlate results. This adds the cluster name to the banner so each output is self-identifying.

What this PR does / why we need it?

Prints kor cluster: <name> above the version line in the banner, sourced from the current kubeconfig context's cluster field. Omitted silently when unavailable (in-cluster, no context, etc.).

Example output:

kor cluster: my-production-cluster
kor version: v0.6.7

  _  _____  ____
 | |/ / _ \|  _ \
 | ' / | | | |_) |
 | . \ |_| |  _ <
 |_|\_\___/|_| \_\

 Powered by Korpro.io

Key changes:

  • pkg/kor/kor.go — Added GetClusterName(kubeconfig string) string: loads kubeconfig via the standard loading rules, walks currentContext → context.cluster, returns empty string on any failure
  • pkg/utils/banner.goPrintLogo gains a clusterName string parameter; prints the cluster line only when non-empty; no change to JSON/YAML output paths
  • cmd/kor/*.go (26 files) — All PrintLogo call sites updated to pass kor.GetClusterName(kubeconfig)

PR Checklist

  • This PR adds K8s exceptions (false positives)
  • This PR adds new code
  • This PR includes tests for new/existing code
  • This PR adds docs

Notes for your reviewers

GetClusterName intentionally does not short-circuit to in-cluster detection (unlike GetConfig) — running inside a pod with no kubeconfig just returns "" and the line is suppressed, which is the correct UX.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature: Include cluster name in the output</issue_title>
<issue_description>Consider the following scenario: I've started using this tool with multiple clusters. I deploy the CronJob via Helm and send messages to a Slack channel using the same webhook for all of them. If scans are set to perform around the same time, it can be hard to correlate which scan is related to what cluster. Although I could use different Slack Apps for each, I think a better solution would involve printing contextual information within the tool output. The output could look something like this:

kor context: kubernetes-cluster-name
kor version: v0.6.7

  _  _____  ____
 | |/ / _ \|  _ \
 | ' / | | | |_) |
 | . \ |_| |  _ <
 |_|\_\___/|_| \_\

 Powered by Korpro.io

Unused resources in namespace: "..."

+---+---------------+---------------------------+
| # | RESOURCE TYPE |       RESOURCE NAME       |
+---+---------------+---------------------------+
| 1 | ...           |            ...            |
+---+---------------+---------------------------+
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: yonahd <47282577+yonahd@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cluster name to output for better context feat: include cluster name in banner output Mar 16, 2026
Copilot AI requested a review from yonahd March 16, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Include cluster name in the output

2 participants