chartmuseum / helm-push

Helm plugin to push chart package to ChartMuseum
Apache License 2.0
674 stars 170 forks source link

Error: 401: could not properly parse response JSON UNAUTHORIZED #143

Open devent opened 2 years ago

devent commented 2 years ago

I have Harbor 2.4.2 running with a robot account for scripts. The robot account have all permissions to all projects.

I changed the robot prefix to robot_

This works:

helm repo add --username="robot_jenkins" --password="xxx" robobeerun https://harbor.anrisoftware.com/chartrepo/robobeerun

If I try to push I get the error:

helm cm-push . robobeerun                                  
W0415 21:56:55.053749 1424714 loader.go:221] Config not found: /home/devent/.kube/config
W0415 21:56:55.054125 1424714 loader.go:221] Config not found: /home/devent/.kube/config
W0415 21:56:55.054278 1424714 loader.go:221] Config not found: /home/devent/.kube/config
Pushing certs-1.0.3.tgz to robobeerun...
Error: 401: could not properly parse response JSON: {"errors":[{"code":"UNAUTHORIZED","message":"UnAuthorized"}]}

Usage:
  helm cm-push [flags]

Flags:
      --access-token string             Send token in Authorization header [$HELM_REPO_ACCESS_TOKEN]
  -a, --app-version string              Override app version pre-push
      --auth-header string              Alternative header to use for token auth [$HELM_REPO_AUTH_HEADER]
      --ca-file string                  Verify certificates of HTTPS-enabled servers using this CA bundle [$HELM_REPO_CA_FILE]
      --cert-file string                Identify HTTPS client using this SSL certificate file [$HELM_REPO_CERT_FILE]
      --check-helm-version              outputs either "2" or "3" indicating the current Helm major version
      --context-path string             ChartMuseum context path [$HELM_REPO_CONTEXT_PATH]
      --debug                           Enable verbose output
  -d, --dependency-update               update dependencies from "requirements.yaml" to dir "charts/" before packaging
  -f, --force                           Force upload even if chart version exists
  -h, --help                            help for helm
      --home string                     Location of your Helm config. Overrides $HELM_HOME (default "/home/devent/.helm")
      --host string                     Address of Tiller. Overrides $HELM_HOST
      --insecure                        Connect to server with an insecure way by skipping certificate verification [$HELM_REPO_INSECURE]
      --key-file string                 Identify HTTPS client using this SSL key file [$HELM_REPO_KEY_FILE]
      --keyring string                  location of a public keyring (default "/home/devent/.gnupg/pubring.gpg")
      --kube-context string             Name of the kubeconfig context to use
      --kubeconfig string               Absolute path of the kubeconfig file to be used
  -p, --password string                 Override HTTP basic auth password [$HELM_REPO_PASSWORD]
      --tiller-connection-timeout int   The duration (in seconds) Helm will wait to establish a connection to Tiller (default 300)
      --tiller-namespace string         Namespace of Tiller (default "kube-system")
  -t, --timeout int                     The duration (in seconds) Helm will wait to get response from chartmuseum (default 30)
  -u, --username string                 Override HTTP basic auth username [$HELM_REPO_USERNAME]
  -v, --version string                  Override chart version pre-push

Error: plugin "cm-push" exited with error
devent commented 2 years ago

It works with a regular user.

Are robot users not supported?

DavidRayner commented 2 years ago

I can successfully push to a Harbor charts museum if I use the unchanged username in single quotes to prevent variable expansion

e.g. a command that fails with the error you're seeing: helm cm-push --username="robot$jenkins" --password="omitted" chart-1.0.0.tgz charts_museum

command that works: helm cm-push --username='robot$jenkins' --password="omitted" chart-1.0.0.tgz charts_museum

abessifi commented 1 year ago

I have the same issue with a harbor robot account. I've followed the instructions here but is doesn't work. Also tested with the --access-token=<robot-secret> and it seems not to work too. Any help please ?