Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parse environment variable replacement tokens in .snag.yml #42

Closed
robertoandrade opened this issue Sep 1, 2015 · 7 comments · Fixed by #46
Closed

Parse environment variable replacement tokens in .snag.yml #42

robertoandrade opened this issue Sep 1, 2015 · 7 comments · Fixed by #46

Comments

@robertoandrade
Copy link

Do you guys think there's value in using environment variables replacement tokens inside .snag.yml so I can have the paths to scripts be configurable per user environment?

Is there any other way you would rather have this be passed to snag so it knows where to look for the files other than adding them to the PATH?

@zabawaba99 zabawaba99 self-assigned this Sep 1, 2015
@zabawaba99
Copy link
Collaborator

I think exporting variables in the shell that snag is running in or passing variables directly to snag might be a better approach than having environment variables in the .snag.yml.

Have you tried doing something like:

PATH=$PATH:/path/to/my/scripts snag

@Tonkpils
Copy link
Owner

Tonkpils commented Sep 1, 2015

@zabawaba99 if that works then that'd be sweet. Does spawning off a new process to handle the request take the global env vars or would it include the one defined when calling the snag command.

@zabawaba99
Copy link
Collaborator

I've used the snippet that I posted before. If I remember correctly, the exec package takes a snapshot of the current environment and passes it along to the process it spawns.

@Tonkpils
Copy link
Owner

Tonkpils commented Sep 5, 2015

@robertoandrade does that work for you or do you still see value in allowing env vars in the snag file?

@robertoandrade
Copy link
Author

well, say I wanted to pass a parameter to one of the commands... that was available as an env variable... say: - doIt $SOME_ENV_INFO.

For me to be able to pre-set the env variables and have them be picked up by doIt, I'd need to then wrap the command in a shell script to be able to pull the variable before passing in to the thing I wanted executed in the first place.

Your suggestion works well for PATH, but I don't think it addresses the other use cases.

@Tonkpils
Copy link
Owner

@robertoandrade I think I understand your use case a bit better now. @zabawaba99 let's chat and think of possible ways to approach this or if you already have thoughts on how to solve this let me know. I'd be happy to see a PR for this.

@zabawaba99
Copy link
Collaborator

I see the issue now, using - doIt $SOME_ENV_INFO doesn't work at the moment because the go exec command treats everything as strings. In order to support this we would need to make code changes when parsing the command, not necessarily the configuration itself.

@zabawaba99 zabawaba99 added this to the v1.1.0 milestone Oct 13, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants