Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 19, 2025

This PR implements automatic creation of cache directories specified by HELM_GIT_REPO_CACHE and HELM_GIT_CHART_CACHE environment variables, addressing the issue where users encounter errors when these directories don't exist.

Problem

When users set cache environment variables to non-existent directories, the plugin fails with errors like:

HELM_GIT_REPO_CACHE:~/.cache/helm/git-helm/repo is not a directory, cannot cache
cd: can't cd to ~/.cache/helm/git-helm/chart/759d8bd436d994883a6f8e8441308d3e

This occurs because the plugin checks for directory existence but doesn't create them automatically.

Solution

The fix adds automatic directory creation during cache enablement with the following features:

  • Automatic creation: Uses mkdir -p to create cache directories and parent paths
  • Error handling: Provides clear error messages if directory creation fails due to permissions
  • Minimal impact: Changes only affect the cache enablement section of the code
  • No manual path manipulation: Relies on shell expansion for path handling

Example Usage

The following command now works out of the box:

HELM_GIT_REPO_CACHE='/tmp/helm-git/repo' \
HELM_GIT_CHART_CACHE='/tmp/helm-git/chart' \
helm repo add wazuh-helm 'git+https://github.com/lucasfcnunes/wazuh-helm@?ref=v0.0.1'

Testing

Added comprehensive test coverage in 06-helm-git-cache.bats including:

  • Nested directory paths
  • Absolute paths
  • Both repo and chart cache combinations
  • Tests for automatic directory creation alongside existing cache functionality tests

All existing tests continue to pass, ensuring no regressions.

Documentation

The README now documents that cache directories are automatically created when specified, providing users with clear expectations about the caching functionality.

Fixes #303.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Automatically create HELM_GIT_*_CACHE folders Automatically create HELM_GIT_*_CACHE folders Aug 19, 2025
Copilot AI requested a review from aslafy-z August 19, 2025 12:59
Copilot finished work on behalf of aslafy-z August 19, 2025 12:59
@aslafy-z
Copy link
Owner

@copilot do not handle tilde manually.

Copy link
Contributor Author

Copilot AI commented Aug 19, 2025

@copilot do not handle tilde manually.

Removed manual tilde expansion handling as requested. The implementation now focuses purely on automatic cache directory creation without manual path manipulation. Commit: 226eee0

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https origin REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of aslafy-z August 19, 2025 13:11
@aslafy-z
Copy link
Owner

@copilot

  • consolidate tests from 07 into 06-helm-git-cache
  • update pr description

Copy link
Contributor Author

Copilot AI commented Aug 19, 2025

@copilot

  • consolidate tests from 07 into 06-helm-git-cache
  • update pr description

Completed both tasks:

  1. ✅ Consolidated tests from 07-auto-create-cache-dirs.bats into 06-helm-git-cache.bats and removed the separate file
  2. ✅ Updated PR description with final implementation details

All tests continue to pass. Commit: 6802457

Copilot finished work on behalf of aslafy-z August 19, 2025 13:17
@aslafy-z aslafy-z marked this pull request as ready for review August 19, 2025 13:32
@aslafy-z aslafy-z changed the title Automatically create HELM_GIT_*_CACHE folders feat: Automatically create HELM_GIT_*_CACHE folders Aug 19, 2025
@aslafy-z
Copy link
Owner

@copilot Add a mention to the readme would be nice.

Copy link
Contributor Author

Copilot AI commented Aug 19, 2025

@copilot Add a mention to the readme would be nice.

Added documentation to README about automatic cache directory creation in the environment variables section. Commit: 99710b7

Copilot AI and others added 5 commits September 30, 2025 09:38
- Auto-create HELM_GIT_REPO_CACHE directory if it doesn't exist
- Auto-create HELM_GIT_CHART_CACHE directory if it doesn't exist
- Handle tilde (~) expansion to home directory properly
- Add comprehensive tests for new functionality
- All existing cache tests continue to pass
- Use inline error handling instead of calling error function
- Ensure proper error messages when directory creation fails
- Error function not available during early script sourcing phase
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.

Automatically create HELM_GIT_*_CACHE folders

2 participants