Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Chartify is a Go library and CLI tool that converts Kubernetes resource YAMLs, K
## Working Effectively

### Bootstrap and Build
- **Prerequisites**: Go 1.24+, Helm v3.18.6, Kustomize v5.6.0+ are required
- **Prerequisites**: Go 1.25.4+, Helm v4.0.0, Kustomize v5.8.0+ are required
- Build the CLI: `go build -o chartify ./cmd/chartify` -- takes 25 seconds. **NEVER CANCEL**. Set timeout to 60+ seconds.
- Build dependencies: `go mod download` -- takes 15 seconds. **NEVER CANCEL**. Set timeout to 120+ seconds.
- Alternative build with chart repo server: `go build -o chartreposerver ./cmd/chartreposerver`
Expand Down Expand Up @@ -72,7 +72,7 @@ Chartify is a Go library and CLI tool that converts Kubernetes resource YAMLs, K
- The CLI expects exactly 2 positional arguments: RELEASE_NAME and CHART_PATH, with -o flag for output directory.

## CI/CD Integration
- GitHub Actions run on Go 1.24+ with Helm v3.18.6 and Kustomize v5.6.0
- GitHub Actions run on Go 1.25.4+ with Helm v4.0.0 and Kustomize v5.8.0
- CI runs `CGO_ENABLED=0 go test ./...` after attempting to add helm stable repo
- Linting workflow uses golangci-lint v2.1.6 but has configuration compatibility issues

Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ on:
branches: [main, master]
jobs:
build:
name: test
name: test (helm ${{ matrix.helm-version }})
runs-on: ubuntu-latest
strategy:
matrix:
helm-version:
- v3.19.2
- v4.0.0
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5
Expand All @@ -20,15 +25,16 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v4.3.1
with:
version: v3.19.0 # default is latest (stable)
version: ${{ matrix.helm-version }}

- name: Install Kustomize
uses: syntaqx/setup-kustomize@v1
with:
kustomize-version: 5.6.0
kustomize-version: 5.8.0

- name: Test
run: |
helm version
helm repo add stable https://charts.helm.sh/stable

CGO_ENABLED=0 go test ./...
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Golangci lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1.6
version: v2.6.2
23 changes: 19 additions & 4 deletions chartify.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/otiai10/copy"
"helm.sh/helm/v3/pkg/registry"
registryv3 "helm.sh/helm/v3/pkg/registry"
registryv4 "helm.sh/helm/v4/pkg/registry"
)

var (
Expand Down Expand Up @@ -84,6 +85,10 @@ type ChartifyOpts struct {
// https://github.com/roboll/helmfile/issues/1547
SkipDeps bool

// OCIPlainHTTP uses plain HTTP for OCI registries when running helm dependency commands.
// Required for local/insecure OCI registries in Helm 4.
OCIPlainHTTP bool

// IncludeCRDs is a Helm 3 only option. When it is true, chartify passes a `--include-crds` flag
// to helm-template.
IncludeCRDs bool
Expand Down Expand Up @@ -378,7 +383,12 @@ func (r *Runner) Chartify(release, dirOrChart string, opts ...ChartifyOption) (s
} else {
// Flatten the chart by fetching dependent chart archives and merging their K8s manifests into the temporary local chart
// So that we can uniformly patch them with JSON patch, Strategic-Merge patch, or with injectors
_, err := r.run(nil, r.helmBin(), "dependency", "up", tempDir)
depArgs := []string{"dependency", "up", tempDir}
// Helm 4 requires --plain-http for HTTP-only OCI registries
if u.OCIPlainHTTP && r.IsHelm4() {
depArgs = append(depArgs, "--plain-http")
}
_, err := r.run(nil, r.helmBin(), depArgs...)
if err != nil {
return "", err
}
Expand All @@ -388,7 +398,12 @@ func (r *Runner) Chartify(release, dirOrChart string, opts ...ChartifyOption) (s
// and its dependencies. But ovbiously, previous `helm fetch` run doesn't download the adhoc dependencies we added
// after running `helm fetch`.
// We need to download adhoc dependencies on our own by running helmfile dependency up.
_, err := r.run(nil, r.helmBin(), "dependency", "up", tempDir)
depArgs := []string{"dependency", "up", tempDir}
// Helm 4 requires --plain-http for HTTP-only OCI registries
if u.OCIPlainHTTP && r.IsHelm4() {
depArgs = append(depArgs, "--plain-http")
}
_, err := r.run(nil, r.helmBin(), depArgs...)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -521,7 +536,7 @@ func (r *Runner) ReadAdhocDependencies(u *ChartifyOpts) ([]Dependency, error) {
if isLocalChart {
name = filepath.Base(d.Chart)
repoUrl = fmt.Sprintf("file://%s", d.Chart)
} else if registry.IsOCI(d.Chart) {
} else if (r.IsHelm3() && registryv3.IsOCI(d.Chart)) || (r.IsHelm4() && registryv4.IsOCI(d.Chart)) {
name = filepath.Base(d.Chart)
// Trim trailing slash to avoid invalid repository error due to duplicate slash in oci registry url
// while running helm dependency up
Expand Down
8 changes: 7 additions & 1 deletion chartify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ func TestUseHelmChartsInKustomize(t *testing.T) {
repo := "myrepo"
startServer(t, repo)

r := New(UseHelm3(true), HelmBin(helm))
r := New(HelmBin(helm))

// Skip this test for Helm 4 as Kustomize 5.8.0 doesn't support Helm 4 yet
// Kustomize tries to run 'helm version -c --short' which is not supported in Helm 4
if r.IsHelm4() {
t.Skip("Skipping test: Kustomize 5.8.0 does not support Helm 4 (uses unsupported 'helm version -c' flag)")
}

tests := []struct {
name string
Expand Down
Loading