chartify icon indicating copy to clipboard operation
chartify copied to clipboard

Allow using kubectl built-in kustomize if separate kustomize binary is missing

Open Copilot opened this issue 6 months ago • 1 comments

This PR implements automatic fallback to kubectl's built-in kustomize functionality when a standalone kustomize binary is not available, addressing the need for better accessibility when only kubectl is installed.

Changes Made

Core Functionality

  • Automatic Fallback Detection: Added logic to detect when kustomize binary is missing and automatically fall back to kubectl kustomize for build operations
  • Direct YAML Generation: Replaced kustomize edit commands with direct YAML file generation using Go structs, eliminating the need for edit operations that aren't supported by kubectl kustomize
  • Smart Command Selection: Implemented kustomizeBuildCommand() method that chooses the appropriate command based on binary availability

Technical Improvements

  • Modern Kustomization Format: Updated to use resources field instead of deprecated bases field, eliminating deprecation warnings
  • Version-Agnostic Flag Handling: Enhanced version detection to gracefully handle missing binaries and use modern flag formats when version cannot be determined
  • Maintained Compatibility: All existing functionality with standalone kustomize binary remains unchanged

Example Usage

Before this change, users needed both helm and kustomize binaries:

# This would fail if kustomize wasn't installed
chartify myapp ./kustomization-dir

After this change, kubectl's built-in kustomize automatically serves as fallback:

# This now works with just kubectl installed
chartify myapp ./kustomization-dir  # Uses kubectl kustomize if kustomize binary missing

The implementation maintains full feature compatibility including:

  • Image tag replacement
  • Name prefix/suffix configuration
  • Namespace settings
  • Alpha plugins support
  • Load restrictor configuration

Testing

Added comprehensive tests to verify:

  • Fallback functionality works when kustomize binary is missing
  • Normal kustomize behavior is preserved when binary is available
  • Generated kustomization.yaml files use modern format
  • All existing functionality continues to work correctly

The solution provides seamless user experience - users don't need to install separate kustomize binary if they already have kubectl with built-in kustomize support.

Fixes #63.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Aug 23 '25 23:08 Copilot