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

Feature: Support Windows #121

Open
ziaenezhad opened this issue Oct 31, 2020 · 10 comments
Open

Feature: Support Windows #121

ziaenezhad opened this issue Oct 31, 2020 · 10 comments
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed

Comments

@ziaenezhad
Copy link

helm-git doesn't work on my Windows 10

helm-git version: 0.8.1

Steps To Reproduce

  1. Running :
helm repo add cert-manager git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2

Shows this error:

Error: looks like "git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2" is not a valid chart repository or cannot be reached: exec: "C:\\Users\\Sajjad\\AppData\\Roaming\\helm\\plugins\\helm-git\\helm-git": file does not exist
@ziaenezhad ziaenezhad added the bug Something isn't working label Oct 31, 2020
@aslafy-z
Copy link
Owner

I have no windows system to try this on. Can you enable debugging with export HELM_GIT_DEBUG=1 and post the output?
Thanks

@ziaenezhad
Copy link
Author

I did, but no more information, just like before:

Error: looks like "git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2" is not a valid chart repository or cannot be reached: exec: "C:\\Users\\Sajjad\\AppData\\Roaming\\helm\\plugins\\helm-git\\helm-git": file does not exist

@ziaenezhad
Copy link
Author

I worked a bit more on it.
The error was because we can't directly execute shell scripts on windows. so I made a new file helm-git.bat and set the command attribute within plugin.yaml to trigger this one, instead of the default to wrap the shell script:

sh ./helm-git %0 "%2" "%3" %4

now I'm getting this:

$ helm repo add cert-manager git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2
write /dev/stdout: The pipe is being closed.
Error: looks like "git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2" is not a valid chart repository
or cannot be reached: error converting YAML to JSON: yaml: line 5: mapping values are not allowed in this context

any idea?

@aslafy-z
Copy link
Owner

Thanks for taking time to work on this. Is debugging enabled?

@ziaenezhad
Copy link
Author

nope, it's with the debugging:

helm repo add cert-manager git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2
write /dev/stdout: The pipe is being closed.
Warning in plugin 'helm-git': git_ref is empty, defaulted to 'master'. Prefer to pin GIT ref in URI.
Debug in plugin 'helm-git': repo: https://github.com/jetstack/cert-manager ref: master path: deploy/charts file: index.yaml sparse: 1 depupdate: 1
Debug in plugin 'helm-git': helm_repo_uri: git+https://github.com/jetstack/cert-manager@deploy/charts?ref=master&sparse=1&depupdate=1
Error: looks like "git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 5: mapping values are not allowed in this context

@aslafy-z
Copy link
Owner

Can you try with the following build (with debug enabled): #133
I added some logs to try to nail the issue

@ziaenezhad
Copy link
Author

yes:

$ helm repo add cert-manager git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2
write /dev/stdout: The pipe is being closed.
Warning in plugin 'helm-git': git_ref is empty, defaulted to 'master'. Prefer to pin GIT ref in URI.
Debug in plugin 'helm-git': repo: https://github.com/jetstack/cert-manager ref: master path: deploy/charts file: index.yaml sparse: 1 depupdate: 1
Debug in plugin 'helm-git': helm_repo_uri: git+https://github.com/jetstack/cert-manager@deploy/charts?ref=master&sparse=1&depupdate=1
Debug in plugin 'helm-git': helm index produced at /tmp/helm-git.Lp6Iqi/index.yaml: apiVersion: v1
entries:
  cert-manager:
  - apiVersion: v1
    appVersion: v0.1.0
    created: "2020-11-18T08:13:45.3239102+03:30"
    description: A Helm chart for cert-manager
    digest: cfbf6057fbc395ea243f747221c749515cc78324da3bc624bcd6aee074d7855b
    home: https://github.com/jetstack/cert-manager
    icon: https://raw.githubusercontent.com/jetstack/cert-manager/master/logo/logo.png
    keywords:
    - cert-manager
    - kube-lego
    - letsencrypt
    - tls
    maintainers:
    - email: [email protected]
      name: munnerz
    name: cert-manager
    sources:
    - https://github.com/jetstack/cert-manager
    urls:
    - git+https://github.com/jetstack/cert-manager@deploy/charts/cert-manager-v0.1.0.tgz?ref=master&sparse=1&depupdate=1
    version: v0.1.0
generated: "2020-11-18T08:13:45.3209792+03:30"
Error: looks like "git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 5: mapping values are not allowed in this context

Also, I'm getting these params in my bat file, if helps:

echo "%0 %1 %2 %3 %4 %5"
"C:\Users\Sajjad\AppData\Roaming\helm\plugins\helm-git\helm-git.bat "" "" "" git+https://github.com/jetstack/cert-manager@deploy/charts/index.yaml?ref v0.6.2 "

@aslafy-z
Copy link
Owner

aslafy-z commented Jun 7, 2022

I think you may need to quote the %4 in your bat file.

@aslafy-z
Copy link
Owner

@sajjad-shirazy Any updates?

@frizzr
Copy link

frizzr commented Sep 24, 2022

@aslafy-z While I would absolutely love to have this plugin working on Windows, I definitely sympathize with the difficulty of getting shell scripts running on Windows.

If you don't mind some unsolicited advice on a different direction you could look at for a short-term workaround...

Keep in mind this is just an idea, I would need to test it a bit with a local copy of your plugin:

Make a Windows-compatible version by

  1. Requiring Windows users to have busybox.exe for Windows in their path, giving Windows users the ability to effectively run your sh scripts unmodified
  2. Changing your helm-git root script to be compatible with both Windows (bat) and Linux (sh) by using these principles, which effectively gives you separate sections of this single file to put both Windows BAT code and sh code into while allowing the same file to be run on both platforms.
  3. Finally, you embed this code into the Windows BAT code section (and of course give credit to skanga for a good idea!) which would then use busybox for Windows to run your child script (helm-git-plugin.sh.) You would need to slightly modify the BAT code linked here to directly run the helm-git-plugin.sh script instead of using the default logic that uses the name of the script where the BAT code runs.

The nice thing about busybox is that it is smart enough to back out to Windows when it cannot find an executable, so git, for example, would call the Windows git executable.

It's not a long-term solution. For that, I would recommend making a powershell version of your helm-git-plugin.sh. Powershell comes with Windows anyway and it is easier to convert from sh to Powershell than it is from sh to BAT. Then you could rework the root helm-git script with the same framework as above, but the BAT section would then call Powershell instead of busybox.

@aslafy-z aslafy-z added help wanted Extra attention is needed enhancement New feature or request and removed bug Something isn't working labels Oct 6, 2022
@aslafy-z aslafy-z changed the title Bug: Fail on windows 10 Feature: Support Windows Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants