Skip to content

helm depdendency update ignoring repository config #371

Description

@davedaemon

I was trying to get a chart like this to download its depdencies from an authenticated repo I'd added with helm repo add.

apiVersion: v2
name: my-umbrella
description: Aggregated Helm chart
type: application
version: 1.0.0
dependencies:
- name: generic-service-chart
  version: 1.0.0-SNAPSHOT
  repository: "@helm-repo"
  alias: alias1
- name: generic-service-chart
  version: 1.0.0-SNAPSHOT
  repository: "@helm-repo"
  alias: alias2
- name: generic-service-chart
  version: 1.0.0-SNAPSHOT
  repository: "@helm-repo"
  alias: alias3

I consistently got this error

Exception in thread "main" java.lang.IllegalStateException: no repository definition for @helm-repo, @helm-repo, @helm-repo. Please add them via 'helm repo add'
	at com.marcnuri.helm.HelmCommand.run(HelmCommand.java:54)
	at com.marcnuri.helm.DependencyCommand$DependencySubcommand.call(DependencyCommand.java:88)

I tried all sorts of variations of environment settings and eventually looked at the source code.

If we look at the command line version of helm dependency update

https://github.com/helm/helm/blob/release-3.9/cmd/helm/dependency_update.go

We can see it is correctly propagating RepositoryConfig

			man := &downloader.Manager{
				Out:              out,
				ChartPath:        chartpath,
				Keyring:          client.Keyring,
				SkipUpdate:       client.SkipRefresh,
				Getters:          getter.All(settings),
				RegistryClient:   cfg.RegistryClient,
				RepositoryConfig: settings.RepositoryConfig,
				RepositoryCache:  settings.RepositoryCache,
				Debug:            settings.Debug,
			}

whereas if we look at helm-java, we can see that RepositoryConfig and RepositoryCache are not being passed.

https://github.com/manusa/helm-java/blob/main/native/internal/helm/dependency.go

	manager := &downloader.Manager{
		Out:            out,
		ChartPath:      options.Path,
		Keyring:        options.Keyring,
		SkipUpdate:     options.SkipRefresh,
		RegistryClient: registryClient,
		Debug:          options.Debug,
		Getters:        getter.All(settings),
	}

Therefore I believe this is defaulting to the empty string?

And this function in https://github.com/helm/helm/blob/release-3.9/pkg/downloader/chart_downloader.go makes the error silent when it's unable to find the empty string config

func loadRepoConfig(file string) (*repo.File, error) {
	r, err := repo.LoadFile(file)
	if err != nil && !os.IsNotExist(errors.Cause(err)) {
		return nil, err
	}
	return r, nil
} 

So the end result is that the helm dependency commands can never work with repositories that require config.

The helm-java repo commands are correctly deriving a default settings.RepositoryConfig here:

https://github.com/manusa/helm-java/blob/main/native/internal/helm/helm.go#L196C1-L202C2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions