Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kustomize/helmCharts: omitting helmChart.repo value does not fallback cleanly to local chartHome #5818

Open
DClabaut opened this issue Nov 28, 2024 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@DClabaut
Copy link

DClabaut commented Nov 28, 2024

What happened?

This documentation page specifies a way to load a local Chart by omitting helmCharts.repo value and specifying helmGlobals.chartHome instead.

This method does not work, as chartHome does not appear to be taken into account at all:

What did you expect to happen?

Helm chart should be loaded from mycharts/

How can we reproduce it (as minimally and precisely as possible)?

Get the chart by using the valid remote repo:

$ tree -L 3
.
└── kustomization.yaml

0 directories, 1 file
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmGlobals:
  chartHome: mycharts

helmCharts:
  - name: harbor
    repo: https://helm.goharbor.io
    releaseName: harbor
    version: 1.16.0
$ kustomize build --enable-helm . > /dev/null
$ tree -L 3
.
├── kustomization.yaml
└── mycharts
    └── harbor-1.16.0
        ├── harbor
        └── harbor-1.16.0.tgz

Try to load the chart from the local custom repo by commenting helmCharts.repo:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmGlobals:
  chartHome: mycharts

helmCharts:
  - name: harbor
    #repo: https://helm.goharbor.io
    releaseName: harbor
    version: 1.16.0
$ kustomize build --enable-helm . > /dev/null
Error: no repo specified for pull, no chart found at ''

Dirty workaround: set different value for helmGlobals.chartHome, specifying one folder down:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmGlobals:
  chartHome: mycharts/harbor-1.16.0

helmCharts:
  - name: harbor
    #repo: https://helm.goharbor.io
    releaseName: harbor
    version: 1.16.0

Command now runs:

$ kustomize build --enable-helm . > /dev/null
$ echo $?
0

Expected output

Rendered Helm chart

Actual output

Error: no repo specified for pull, no chart found at ''

Kustomize version

5.5.0

Operating system

Linux

@DClabaut DClabaut added the kind/bug Categorizes issue or PR as related to a bug. label Nov 28, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 28, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@DClabaut
Copy link
Author

Closing issue, the empty harbor-1.16.0.tgz folder had not been copied

@DClabaut DClabaut changed the title Kustomize/helmCharts: custom chartHome not taken into account Kustomize/helmCharts: custom chartHome does not work Nov 28, 2024
@DClabaut
Copy link
Author

Reopening with more details - can reproduce consistently now

@DClabaut DClabaut reopened this Nov 28, 2024
@DClabaut DClabaut changed the title Kustomize/helmCharts: custom chartHome does not work Kustomize/helmCharts: omitting helmChart.repo value does not fallback cleanly to local chartHome Nov 28, 2024
@aarnaud
Copy link

aarnaud commented Nov 28, 2024

Introduce by a0f131c
#4999

func (p *plugin) absChartHome() string {
	var chartHome string
	if filepath.IsAbs(p.ChartHome) {
		chartHome = p.ChartHome
	} else {
		chartHome = filepath.Join(p.h.Loader().Root(), p.ChartHome)
	}

	if p.Version != "" && p.Repo != "" {
		return filepath.Join(chartHome, fmt.Sprintf("%s-%s", p.Name, p.Version))
	}
	return chartHome
}

should be

func (p *plugin) absChartHome() string {
	var chartHome string
	if filepath.IsAbs(p.ChartHome) {
		chartHome = p.ChartHome
	} else {
		chartHome = filepath.Join(p.h.Loader().Root(), p.ChartHome)
	}

	if p.Version != ""  {
		return filepath.Join(chartHome, fmt.Sprintf("%s-%s", p.Name, p.Version))
	}
	return chartHome
}

aarnaud added a commit to aarnaud/kustomize that referenced this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

3 participants