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

Support Windows #7

Closed
2 of 3 tasks
jkroepke opened this issue Apr 26, 2020 · 12 comments
Closed
2 of 3 tasks

Support Windows #7

jkroepke opened this issue Apr 26, 2020 · 12 comments

Comments

@jkroepke
Copy link
Owner

jkroepke commented Apr 26, 2020

Goal:

  • Run helm plugin install from windows cmd
  • Run helm secrets from windows cmd
  • Support sops.exe if no sops installed on WSL. (This supports gpg programs like gpg4win)
@jkroepke jkroepke changed the title Support WSL Support Windows WSL Apr 26, 2020
@jkroepke jkroepke changed the title Support Windows WSL Support Windows May 7, 2020
@erihanse
Copy link

@jkroepke do you know if there is a roadmap for windows support? We're getting

C:\Windows\system32>helm plugin install https://github.com/futuresimple/helm-secrets --version 2.0.2
Error: exec: "sh": executable file not found in %PATH%

@jkroepke jkroepke reopened this Aug 20, 2020
@jkroepke
Copy link
Owner Author

jkroepke commented Aug 20, 2020

@erihanse I tought no one request it.

One question:

do you have installed Git for Windows or WSL(Ubuntu Bash) on your system?

I saw you are using the old futuresimple version.

What the error if you try

helm plugin install https://github.com/jkroepke/helm-secrets

?

@philomory
Copy link

philomory commented Aug 20, 2020

For my part, helm plugin install https://github.com/jkroepke/helm-secrets works perfectly, but when I try e.g. helm secrets --help I get

Error: fork/exec C:\Users\adam.gardner\AppData\Roaming\helm\plugins\helm-secrets/scripts/run.sh: %1 is not a valid Win32 application.

I do have both Git for Windows and WSL2 installed.

@philomory
Copy link

Since I do have sh available, I was able to fix it by manually editing the command field in plugin.yaml to say sh $HELM_PLUGIN_DIR/scripts/run.sh instead of just $HELM_PLUGIN_DIR/scripts/run.sh (since Windows doesn't really have a concept of a "shebang")

@jkroepke
Copy link
Owner Author

@philomory

You could take a look at #28 and see if this works on windows, too?

@philomory
Copy link

@jkroepke Yes, that does appear to work. Obviously it's not going to work for someone who doesn't have any instance of sh anywhere on their PATH, but, having to have at least one of WSL or Git-for-Windows as a prerequisite doesn't seem too onerous.

@jkroepke
Copy link
Owner Author

Sure, correct. But I would rewrite the plugin in go nativly before going to write some powershell. 😄

@philomory
Copy link

So, the new windows sh.cmd doesn't seem to work for me or my coworkers. Previously, when running just sh $HELM_PLUGIN_DIR/scripts/run.sh, everything seemed to work for us. Now, with the use of the new sh.cmd nothing works anymore. We constantly get the message, "The system cannot find the path specified". I've not yet dug into the script to figure out exactly what's going on, I'll let you know what I find.

@jkroepke
Copy link
Owner Author

jkroepke commented Sep 23, 2020

I'll let you know what I find.

Thats a lot!

I just test it on my Windows machine. Since there is no default shell, I had to handle multiple cases (cygwin, git for windows, wsl) and different variations. There was no sh by default available.

The sh.cmd prefers a shell from windows environment first, because I thought if helm-secrets runs in WSL, it can't interact with a gpg deamon runs under windows, eg. gpg4win. But it's possible to force a shell/environment.

@philomory
Copy link

philomory commented Sep 23, 2020

So I can see a few things that seem a bit weird. The windows command in plugin.yaml says cmd /c $HELM_PLUGIN_DIR/wrapper/sh.cmd $HELM_PLUGIN_DIR/scripts/run.sh"; but, $HELM_PLUGIN_DIR/wrapper/sh.cmd doesn't exist, it's $HELM_PLUGIN_DIR/scripts/wrapper/sh.cmd.

After correcting for that issue, the plugin actually works, although there's another (not-fatal) weirdness: If you call helm secrets foo, then the command passed to cmd /c is $HELM_PLUGIN_DIR/scripts/wrapper/sh.cmd $HELM_PLUGIN_DIR/scripts/run.sh foo. So, the arguments to sh.cmd will be $HELM_PLUGIN_DIR/scripts/run.sh foo. So far, so good.

However, inside sh.cmd, on line 47, we call "sh" "%HELM_PLUGIN_DIR%\scripts\run.sh" %*. %* at this point contains %HELM_PLUGIN_DIR/scripts/run.sh foo, so arguments ultimately passed to sh are $HELM_PLUGIN_DIR\scripts\run.sh $HELM_PLUGIN_DIR/scripts/run.sh foo. This actually works, but it's a little confusing and I could see it being a source of issues in the future if the contents of run.sh changed.

jkroepke added a commit that referenced this issue Sep 23, 2020
@jkroepke
Copy link
Owner Author

arguments ultimately passed to sh are $HELM_PLUGIN_DIR\scripts\run.sh $HELM_PLUGIN_DIR/scripts/run.sh foo

Yes, the behavior is catched by

# ./run.sh vs bash run.sh
if [ "$(basename "$1")" = "run.sh" ]; then
shift
fi

This actually works, but it's a little confusing and I could see it being a source of issues in the future if the contents of run.sh changed.

I know this. Additionally it's increase the complexity dramatically.

If we are get more issues, I'll restore the old behavior.

The reason for this, helm-secrets was not running out of the box on my windows systems.

@jkroepke
Copy link
Owner Author

I'm running Windows tests inside GH Actions now. That should avoid some mistakes on windows systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants