-
Notifications
You must be signed in to change notification settings - Fork 177
Description
I'm trying to use the --repository option of the kn CLI to create a function from a template hosted on a GitLab instance, but I get an error about authentication.
Non-working command:
kn func create myfunc -l python -t fastapi --repository "https://<my-gitlab-host>/kn-templates"
The error:
Error: failed to get repository from URI ("https://<my-gitlab-host>/kn-templates"): failed to clone repository: authentication required: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See https://<my-gitlab-host>/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied
The repository visibility settings is set to internal (cue the authentication).
However, I've set up my .gitconfig to use a .git-credentials file in my /home, allowing me to clone the repository without providing any user/password.
$ cat ~/.gitconfig
[credential]
helper = store
...
$ cat ~/.git-credentials
https://<user>:<password>@<my-gitlab-host>
...
Working git clone command:
git clone https://<my-gitlab-host>/kn-templates
If I set the user/password in the URL, kn can clone and create the function.
Working command:
kn func create myfunc -l python -t fastapi --repository "https://<user>:<password>@<my-gitlab-host>/kn-templates"
Is there a way to configure kn to use the .gitconfig/.git-credentials of the user ?
nb: my kn binary comes from the OpenShift instance running locally, referenced in the webpage /command-line-tools. The cluster has the operator Red Hat OpenShift Serverless in version 1.37.0.