Skip to content

Conversation

@weinong
Copy link
Contributor

@weinong weinong commented Jul 21, 2025

  • Introduce unified options architecture for both convert and token commands aiming to simplify options-to-cli flag mapping, validation, and conversion
  • The unified options are enabled by default. Set environment variable KUBELOGIN_USE_LEGACY_OPTIONS=true to fallback to previous implementation
  • Add comprehensive validation with strict/lenient modes for different contexts
  • Implement reflection-based argument building for kubeconfig conversion
  • Add extensive test coverage for unified options and validation
  • Establish breadcrumb documentation system for development decisions

@weinong weinong requested a review from bcho July 21, 2025 17:24
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 61.50289% with 333 lines in your changes missing coverage. Please review.

Project coverage is 56.71%. Comparing base (15edb67) to head (72e90f5).
Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
pkg/internal/options/execution.go 51.44% 183 Missing and 19 partials ⚠️
pkg/internal/options/validation.go 69.47% 53 Missing and 5 partials ⚠️
pkg/internal/options/unified.go 74.03% 41 Missing and 6 partials ⚠️
pkg/internal/options/command.go 63.88% 10 Missing and 3 partials ⚠️
pkg/cmd/convert.go 0.00% 8 Missing ⚠️
pkg/cmd/token.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #689      +/-   ##
==========================================
- Coverage   63.43%   56.71%   -6.73%     
==========================================
  Files          37       47      +10     
  Lines        2210     3269    +1059     
==========================================
+ Hits         1402     1854     +452     
- Misses        733     1280     +547     
- Partials       75      135      +60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bcho bcho requested a review from Copilot July 21, 2025 17:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a unified options system for both convert and token commands aiming to simplify options-to-cli flag mapping, validation, and conversion. The unified options are enabled by default with environment variable KUBELOGIN_USE_LEGACY_OPTIONS=true to fallback to previous implementation.

Key changes include:

  • Introduction of unified options architecture with automatic flag registration using reflection and struct tags
  • Implementation of comprehensive validation with strict/lenient modes for different contexts
  • Addition of reflection-based argument building for kubeconfig conversion with field extraction from existing configurations

Reviewed Changes

Copilot reviewed 31 out of 33 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/integration/test_helpers.go New integration test framework with environment isolation and helper utilities
test/integration/kubeconfig_flag_test.go Tests for --kubeconfig flag support in unified mode
test/integration/go.mod Go module configuration for integration tests
test/integration/fixtures/sample_kubeconfig.yaml Sample kubeconfig fixture for testing conversion scenarios
test/integration/fixtures/empty_kubeconfig.yaml Basic kubeconfig fixture for testing minimal configurations
test/integration/converter_integration_test.go Comprehensive integration tests for all login methods and conversion scenarios
test/integration/cli_integration_test.go CLI argument parsing and environment variable integration tests
pkg/internal/options/validation_test.go Unit tests for validation rules and login method validation
pkg/internal/options/validation.go Validation logic with strict and lenient modes for different command contexts
pkg/internal/options/utils.go Utility functions including ToString() with sensitive field masking
pkg/internal/options/unified_test.go Unit tests for unified options core functionality
pkg/internal/options/unified.go Core unified options struct with automatic flag registration and environment loading
pkg/internal/options/kubeconfig_test.go Tests for kubeconfig flag registration and parsing
pkg/internal/options/field_extraction_diagnostic_test.go Diagnostic tests demonstrating field extraction validation issues
pkg/internal/options/execution_test.go Tests for command execution and options conversion
pkg/internal/options/execution.go Command execution logic with field extraction and kubeconfig conversion
pkg/internal/options/description_consistency_test.go Tests ensuring consistent flag descriptions between legacy and unified modes
pkg/internal/options/convert_test.go Unit tests for conversion logic and exec config building
pkg/internal/options/command_test.go Tests for unified command creation and feature flag behavior
pkg/internal/options/command.go Command creation utilities and feature flag management
pkg/cmd/token.go Integration of unified options in token command with legacy fallback
pkg/cmd/convert.go Integration of unified options in convert command with legacy fallback
Makefile Added integration test targets and output management
.github/instructions/options-and-conversion.instructions.md Comprehensive documentation for unified options system usage
.github/instructions/go.instructions.md Go development best practices and coding standards
.github/copilot-instructions.md Development workflow instructions and breadcrumb protocol
.github/.copilot/breadcrumbs/2025-07-20-1430-flag-description-consistency.md Documentation of flag description consistency improvements
.github/.copilot/breadcrumbs/2025-07-20-1405-extract-login-constants.md Documentation of login constants consolidation refactoring

@weinong weinong force-pushed the copilot/unified-options branch from b9f2902 to 87032d7 Compare July 22, 2025 00:33
- Introduce unified options architecture for both convert and token commands aiming to simplify options-to-cli flag mapping, validation, and conversion
- The unified options are enabled by default. Set environment variable KUBELOGIN_USE_LEGACY_OPTIONS=true to fallback to previous implementation
- Add comprehensive validation with strict/lenient modes for different contexts
- Implement reflection-based argument building for kubeconfig conversion
- Add extensive test coverage for unified options and validation
- Establish breadcrumb documentation system for development decisions
@weinong weinong force-pushed the copilot/unified-options branch from 87032d7 to 72e90f5 Compare July 22, 2025 01:44
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.

2 participants