-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
may be we could pass parameter to script by name #181
Comments
Hi @yosefy could you explain in examples, please, what do you mean? |
there is a name for each parameter
then in the script |
insted of |
or may be we could use the "param" without dashes as name |
To be honest I'm confused. How are you using But in general, as far as I understand, you would like that Script server will create environment variables based on parameters (and their) and pass them to a script, is it correct? Also Script server is based on the vision, that nobody will have a need to adjust their scripts for Script server :) And with this variables, your script would be almost unusable outside of Script server |
actually i am building my scripts for script-server in my case --test to "TEST" i think may be "param" is best candidate for the var name because it cant have spaces in it anyway so that way scripts can continue running without script-server and still be logically connected to this way may be you have better idea? but again it is only for improvement. i am happy with script server anyway :) |
I would use parameter name instead, because "param" should be used in a diferent manner (and it could be a single letter in a lot of cases). But are you using "param" in your scripts at all? If you access parameters by index, then you don't need it. Anyway, the idea itself makes sense |
amm i don't use it like this in this case (mostly using script server with ansible and terraform and packer for now) |
Name should be ok.
But then you can skip specifying |
yes i know but still you have to remember what is this $4 (or was it $3??) you see in the script example from real life :) |
I agree with you, the whole ticket makes perfect sense. By the way, why don't you set variables at the beginning of the script? It will make your life a little bit easier, I guess. Example:
|
well also an option :) also to let you know it solves many problems of not knowing the exact amount of vars that will be there in the end so just wanted to thanks for that :) |
so another reason: terraform apply -var "env=dev" -var "app=test" -var "size=6" and i don't know how many there will be as they come from dynamically included config files for example so, if "app" is not required and not set, then "size" will move from $6 to $4 same with running ansible with multiple -e option or any other software of this type so if we only use it with terraform command , then ok, we just add them all so here turning name to ENV VAR as you suggested may fix the situation completely thanks |
ok after trying all day :) need help but i don't i can't find a way to do it @bugy , may be you have some idea? |
Hi @yosefy, this is not possible, unfortunately. So as usual, my proposal would be some wrapping script. Which will read "normal" parameters and adapt them to the terraform syntax |
Ah right. Somehow I didnt think this way. I'll share if I manage to create
one
…On Mon, Feb 25, 2019, 9:39 PM Iaroslav Shepilov ***@***.***> wrote:
Hi @yosefy <https://github.com/yosefy>, this is not possible,
unfortunately. So as usual, my proposal would be some wrapping script.
Which will read "normal" parameters and adapt them to the terraform syntax
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMVy7bpzl2BRSFWXF7A1jobE-gDAgh2Cks5vRDvpgaJpZM4a506_>
.
|
Ok, if you would need help with it, I'd be glad to help |
I would like to resurface this issue as I'm using lot of scripts that uses environment variables to perform diferent operations. A very simple example:
There's a webmin plugin that handles that very well, you can specify any order an number of variables and you can construct the call to script in any way you want. Then you fill the variables with any value you want. Here you can take a look: what do you think about it? |
Hi @muzzol, to be honest I never worked with webmin and not sure, what does this plugin do. But in general is the idea is to pass parameters to scripts as environment variables, right? I.e. if you have parameters "Your name" and "Your password". In the script you would expect them to be available in $YOUR_NAME and $YOUR_PASSWORD env variables, right? |
Also somehow not to mix with regular placement depending vars I guess. May
be make them like ENV_PASS. With ENV_ prefix
…On Fri, May 17, 2019, 4:45 PM Iaroslav Shepilov ***@***.***> wrote:
Hi @muzzol <https://github.com/muzzol>, to be honest I never worked with
webmin and not sure, what does this plugin do.
But in general is the idea is to pass parameters to scripts as environment
variables, right? I.e. if you have parameters "Your name" and "Your
password". In the script you would expect them to be available in
$YOUR_NAME and $YOUR_PASSWORD env variables, right?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181?email_source=notifications&email_token=ADCXF3P5HVBDVHJBBUU2RBDPV2ZJNA5CNFSM4GXHJ272YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVUZOKY#issuecomment-493459243>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADCXF3JYGZKLOXPHGYDVAYLPV2ZJNANCNFSM4GXHJ27Q>
.
|
yes, that's it. maybe you could make a new parameter configuration, Environment Variable, that transforms that value in a variable just before script execution:
this would be something like:
and if you want a variable from the whole environment you could use your ENV_ prefix trick. |
Done. By default all parameters are mapped to PARAM_{uppercase name}, for example: All whitespaces and special characters are replaced to a single underscore (_), e.g.: All non-ascii letters are tried to be transliterated, e.g.: Buuut, if you want to be explicit, you can set a variable name yourself, using
In this case the name will be exactly The following parameters will not be set as env variables:
PS this will be available in the dev build, and the new admin page already supports |
@Nottt FYI |
Yes! Hanuka miracle :)
…On Wed, Dec 25, 2019, 6:46 PM Iaroslav Shepilov ***@***.***> wrote:
Done. By default all parameters are mapped to PARAM_{uppercase name}, for
example:
id -> PARAM_ID
Server Type -> PARAM_SERVER_TYPE
All whitespaces and special characters are replaced to a single underscore
(_), e.g.:
hello !@#$%^& world -> PARAM_HELLO_WORLD
All non-ascii letters are tried to be transliterated, e.g.:
ῥυθμος -> PARAM_RYTHMOS
Buuut, if you want to be explicit, you can set a variable name yourself,
using env_var field, e.g.:
{
"name": "Required Text",
"required": true,
"param": "--required_text",
"env_var": "Req_Text"
}
In this case the name will be exactly Req_Text and no transformations
will be performed (even if the name is not supported).
The following parameters will *not* be set as env variables:
1. Empty values
2. List values ("type": "multiselect" and "multiple_arguments": true)
3. Non-ascii parameter names and if transliteration is not supported,
e.g. japanese
4. no_value parameters, if the value is false
5. Parameters with a duplicated variable name (either copypasted
env_var or name normalization is the same (e.g. Param ε and Param η
are both resolved to PARAM_E)
PS this will be available in the dev build, and the new admin page already
supports env_var
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#181?email_source=notifications&email_token=ADCXF3L6PID3G43MPR6LP3LQ2OE7LA5CNFSM4GXHJ272YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHUPKEA#issuecomment-568915216>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCXF3IY6IHLPZRBLPBDV4TQ2OE7LANCNFSM4GXHJ27Q>
.
|
because when there are too many it becomes pretty complicated to remember numbers
may be there is such an option?
(i can live without it... just a thought)
thanks
The text was updated successfully, but these errors were encountered: