Skip to content
Open
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
6 changes: 6 additions & 0 deletions pkg/commands/kubeconfig_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func wrapKubeconfigCommand(wrappedCmd *cobra.Command, originalRunE func(*cobra.C
// Add --login flag to update system kubeconfig file instead of local one
wrappedCmd.Flags().BoolP("login", "l", false, "update system kubeconfig file, not local one")

// Fix help text for unused arg [local-path] from talosctl kubeconfig command
wrappedCmd.Use = "kubeconfig"
wrappedCmd.Long = `Download the admin kubeconfig from the node.
If merge flag is true, config will be merged with ~/.kube/config.
Otherwise, kubeconfig will be written to PWD.`
Comment on lines +34 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Long description for the kubeconfig command is inaccurate and could be misleading to users:

  1. It states that the kubeconfig will be written to PWD. However, the implementation writes it to a path relative to the project root (Config.RootDir), which may differ from the current working directory (PWD). The path is determined by globalOptions.kubeconfig in Chart.yaml or defaults to a kubeconfig file in the project root.
  2. It implies that --merge is false by default by describing the if merge flag is true case. The underlying talosctl kubeconfig command defaults --merge to true. The help text should describe the default behavior first to avoid confusion.

A more accurate description would improve user experience.

Suggested change
wrappedCmd.Long = `Download the admin kubeconfig from the node.
If merge flag is true, config will be merged with ~/.kube/config.
Otherwise, kubeconfig will be written to PWD.`
wrappedCmd.Long = `Download the admin kubeconfig from the node.
By default, the config is merged with the default kubeconfig file.
Use --merge=false to write to a file instead. When writing to a file, the path is configured via 'globalOptions.kubeconfig' in your Chart.yaml, defaulting to 'kubeconfig' in the project root.`

Comment on lines +32 to +36
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Update help text to accurately reflect wrapped command behavior.

The Long description appears to describe the original talosctl behavior rather than the wrapped talm behavior. Key discrepancies:

  • Missing --login flag documentation: The help doesn't mention the --login flag, which significantly changes where the kubeconfig is written.
  • Inaccurate default location: States "kubeconfig will be written to PWD" when merge is false, but the actual default behavior (without --login) writes to the path specified in Chart.yaml globalOptions.Kubeconfig, resolved relative to the project root (lines 66-79), not the current working directory.
  • Missing additional behaviors: No mention of automatic .gitignore updates, encryption handling, or server endpoint updates that are unique to the wrapped command.

Consider updating the description to accurately reflect the wrapped command's behavior:

🔎 Suggested help text revision
-	wrappedCmd.Long = `Download the admin kubeconfig from the node.
+	wrappedCmd.Long = `Download the admin kubeconfig from the node.
 
-If merge flag is true, config will be merged with ~/.kube/config.
-Otherwise, kubeconfig will be written to PWD.`
+By default, kubeconfig is written to the path specified in Chart.yaml 
+globalOptions.Kubeconfig (relative to project root). If merge flag is 
+true, config will be merged with ~/.kube/config instead.
+
+Use --login flag to write to a custom location (system kubeconfig) 
+rather than the project's configured path.
+
+The command automatically:
+- Sets secure permissions (600) on the kubeconfig file
+- Adds 'kubeconfig' to .gitignore if written to project root
+- Updates the server endpoint if --endpoints is specified
+- Encrypts to kubeconfig.encrypted if talm.key exists`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Fix help text for unused arg [local-path] from talosctl kubeconfig command
wrappedCmd.Use = "kubeconfig"
wrappedCmd.Long = `Download the admin kubeconfig from the node.
If merge flag is true, config will be merged with ~/.kube/config.
Otherwise, kubeconfig will be written to PWD.`
// Fix help text for unused arg [local-path] from talosctl kubeconfig command
wrappedCmd.Use = "kubeconfig"
wrappedCmd.Long = `Download the admin kubeconfig from the node.
By default, kubeconfig is written to the path specified in Chart.yaml
globalOptions.Kubeconfig (relative to project root). If merge flag is
true, config will be merged with ~/.kube/config instead.
Use --login flag to write to a custom location (system kubeconfig)
rather than the project's configured path.
The command automatically:
- Sets secure permissions (600) on the kubeconfig file
- Adds 'kubeconfig' to .gitignore if written to project root
- Updates the server endpoint if --endpoints is specified
- Encrypts to kubeconfig.encrypted if talm.key exists`
🤖 Prompt for AI Agents
In pkg/commands/kubeconfig_handler.go around lines 32 to 36, the Long help text
still describes the original talosctl behavior; update it to reflect the wrapped
talm behavior: mention the --login flag and that when set kubeconfig is written
to the user’s kubeconfig/login location, otherwise the file is written to the
path from Chart.yaml globalOptions.Kubeconfig (resolved relative to the project
root), clarify the merge flag behavior (merges with target kubeconfig when
true), and include notes about additional behaviors unique to this wrapper
(automatic .gitignore updates, encryption handling, and server endpoint updates)
so users see the full expected effects of the command.


wrappedCmd.RunE = func(cmd *cobra.Command, args []string) error {
// Ensure project root is detected
if !Config.RootDirExplicit {
Expand Down