Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Force powershell on local-exec #44

Merged
merged 9 commits into from
Oct 22, 2019
Merged

Force powershell on local-exec #44

merged 9 commits into from
Oct 22, 2019

Conversation

yorinasub17
Copy link
Contributor

@yorinasub17 yorinasub17 commented Oct 19, 2019

Depends on gruntwork-io/kubergrunt#74

If you look at the code for local-exec, it turns out that it hard codes to cmd instead of doing something intelligent to see if it is run from powershell or cmd. See https://github.com/hashicorp/terraform/blob/master/builtin/provisioners/local-exec/resource_provisioner.go#L79

Unfortunately, cmd doesn't quite cleanly support multiline commands when passed using the /C arg, so instead we need to force Powershell when on windows by using the interpreter attribute.

Additionally, environment variables are read as $env:ENV_VAR on Powershell, so we need to adapt to that as well.

I also ran into issues with json encoding, where the double quotes made Powershell unhappy, so we need to escape those as well.

Testing note

  • Test on windows box

@yorinasub17
Copy link
Contributor Author

Ok I have verified the current version works on my windows box.

@yorinasub17
Copy link
Contributor Author

yorinasub17 commented Oct 19, 2019

Ah looks like there is still a problem with windows. Specifically, the kubectl auth system doesn't work. Since we've run into a few issues with kubectl anyway, I'll work on creating a wrapper in kubergrunt that can run arbitrary kubectl auth'd (since I have verified kubergrunt is properly authing).

Copy link
Contributor

@robmorgan robmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yorinasub17
Copy link
Contributor Author

Thanks for the review! Going to merge this now that kubergrunt is merged.

@yorinasub17 yorinasub17 merged commit d99ec1c into master Oct 22, 2019
@yorinasub17 yorinasub17 deleted the yori-fix-windows branch October 22, 2019 21:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants