Skip to content

fix(sync): Improve Greenhouse kubeconfig loading and error reporting in sync command#47

Merged
onuryilmaz merged 1 commit intomainfrom
kubeconfig-fix
Feb 18, 2026
Merged

fix(sync): Improve Greenhouse kubeconfig loading and error reporting in sync command#47
onuryilmaz merged 1 commit intomainfrom
kubeconfig-fix

Conversation

@onuryilmaz
Copy link
Contributor

Description

This PR improves the robustness and clarity of the sync command when loading the Greenhouse cluster kubeconfig. It addresses a common issue where client-go would report a cryptic "invalid configuration: no configuration has been provided" error when the default context in a kubeconfig file was missing or invalid, even if a specific context was provided via flags.

Key Changes

  • Context-First Loading: If --greenhouse-cluster-context is specified, the tool now attempts to build the REST configuration using that context directly. This bypasses the initial attempt to load the default/current context, which was previously causing premature failures.
  • Explicit File Validation: Added an explicit check for the existence of the Greenhouse kubeconfig file using os.Stat. This ensures a clear "file not found" error is returned instead of the generic Kubernetes configuration error.
  • Enhanced Error Messages: Improved error wrapping to include the specific file path and context name that failed to load, making troubleshooting significantly easier for users.

Why this is needed

Previously, the sync command would call clientcmd.BuildConfigFromFlags("", path) which defaults to the "current-context". If the kubeconfig existed but the current-context was empty or pointed to a non-existent entry, the command would fail immediately, preventing the user-supplied --greenhouse-cluster-context from ever being used.

@onuryilmaz onuryilmaz requested review from a team as code owners February 18, 2026 22:34
@onuryilmaz onuryilmaz merged commit 096101f into main Feb 18, 2026
8 checks passed
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.

1 participant

Comments