feat: CHEF-27550 - Handle missing or invalid kubeconfig file gracefully #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Enhanced kubeconfig error handling to provide clear, user-friendly error messages when users provide missing or invalid kubeconfig files. The plugin now validates kubeconfig options before attempting to load them and provides actionable feedback to help users resolve configuration issues quickly.
This work was completed with AI assistance following Progress AI policies.
Related Issue
Jira Ticket: CHEF-27550
Changes
Enhanced
lib/train-kubernetes/connection.rbwith comprehensive kubeconfig validation:Psych::SyntaxError)K8s::Error)Train::UserErrorwith clear, actionable messagesAdded comprehensive RDoc documentation with examples
Added 3 negative test scenarios in
test/unit/connection_test.rb:test_parse_kubeconfig_missing_option- Validates error when kubeconfig not providedtest_parse_kubeconfig_file_not_found- Validates error for non-existent file pathstest_parse_kubeconfig_invalid_yaml- Validates error for malformed YAML syntaxTest Results
Types of changes
Checklist:
Files Changed
lib/train-kubernetes/connection.rb- Enhancedparse_kubeconfigmethod with validation and error handlingtest/unit/connection_test.rb- Added 3 comprehensive negative test scenarios