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

Add possibility to dynamically include script parameter section #133

Closed
bugy opened this issue Sep 26, 2018 · 22 comments
Closed

Add possibility to dynamically include script parameter section #133

bugy opened this issue Sep 26, 2018 · 22 comments

Comments

@bugy
Copy link
Owner

bugy commented Sep 26, 2018

There should be a possibility to add an "include" section to a script configuration, which would add/fill parameters configuration from another file.
This "include" section can depend on current parameter values, so it will be loaded dynamically while user selects values on UI

There are 2 use cases behind:

  1. Sharing parameters in different configurations
  2. Depending on some parameter, we could include different corresponding additional parameters

For more details and reasoning please read comments in #119

@bugy
Copy link
Owner Author

bugy commented Oct 26, 2018

@yosefy, I've completed this feature. There is a new field include in script configuration section. This could be a static path (e.g. '/home/myuser/included.json') or a dynamic path ('/home/myuser/${parameter name}.json').
If the path is relative, then it will be relative to conf/runners folder.

Included configurations have the same structure as normal configurations. Though only parameters section is supported at the moment (other fields are undocumented/unsupported, so please don't use them).

To avoid loading included files as a standalone configurations, there is a possibility to exclude them with a new field hidden. Any hidden configurations will not be shown to a user and can only be included.

If both base configuration and included configuraition have a parameter with the same name, then included parameter will be ignored.

Example included file (see parameterized.json and included.json from samples for more details):

{
  "hidden": true,
  "parameters": [
    {
      "name": "inc_param1",
      "type": "int"
    },
    {
      "name": "inc_param2",
      "no_value": "true",
      "param": "--inc2"
    }
  ]
}

To support this I had to completely reimplement communication layer when loading script config and starting execution, so it could cause some bugs :(

@bugy bugy added the resolved label Oct 26, 2018
@yosefy
Copy link

yosefy commented Oct 27, 2018 via email

@bugy bugy closed this as completed Jan 25, 2019
@yosefy
Copy link

yosefy commented Feb 25, 2019

sorry just a question, so i cant use values from included file in script?
so how to use it?

@bugy
Copy link
Owner Author

bugy commented Feb 25, 2019

Hi, what do you mean?

@yosefy
Copy link

yosefy commented Feb 25, 2019 via email

@bugy
Copy link
Owner Author

bugy commented Feb 25, 2019

That's extremely strange. Do you see these values on UI? And in the log, before script is called? (or after, in the admin page)

@yosefy
Copy link

yosefy commented Feb 25, 2019

image

{
"hidden": false,
"parameters": [
{
"name": "inc_param1",
"type": "list",
"values": [
"aaa",
"bbb"
]
},
{
"name": "inc_param2",
"no_value": "true",
"param": "--inc2"
}
]
}

script is:

args=("$@")
echo $@

@bugy
Copy link
Owner Author

bugy commented Feb 25, 2019

Ok, apparently it doesn't work at all :( Will fix it

@yosefy
Copy link

yosefy commented Feb 26, 2019

@bugy , do you have some estimation of fixing it
blocking from putting in prod :)

thanks

@bugy
Copy link
Owner Author

bugy commented Feb 26, 2019

Hi, I'm working on another ticket at the moment (#184), and would need 2-3 days there probably.
The fix here will take ~1 day.

So if it's urgent for you, I could work on it today, otherwise estimation is Friday

@bugy bugy reopened this Feb 26, 2019
@bugy bugy removed the resolved label Feb 26, 2019
@yosefy
Copy link

yosefy commented Feb 26, 2019 via email

@bugy
Copy link
Owner Author

bugy commented Feb 26, 2019

Ok, agreed

bugy added a commit that referenced this issue Feb 26, 2019
@bugy bugy added the resolved label Feb 26, 2019
@bugy
Copy link
Owner Author

bugy commented Feb 26, 2019

Fixed. Should be available in the latest stable release (1.13.2) and dev

@yosefy
Copy link

yosefy commented Feb 27, 2019 via email

@bugy
Copy link
Owner Author

bugy commented Mar 23, 2019

Thanks for double-checking and reporting the issue with default values. I moved it to a separate ticket #201

@bugy bugy closed this as completed Mar 23, 2019
@kbza
Copy link

kbza commented Aug 30, 2020

Hello there!
Is there any way of including more than one external included file for script? thinking of one of the following:

  • Multiple include directives (I think it only works the latest)
  • The possibility of an include directive with array as a type.
  • Another include on the included file.

I'm trying to figure out a way of having configuration files that will be the same across installations, some specific to each one and others specific to the servers.
Is there any way of achiving this in the current version? will you consider implementing something like this in the future?

Thanks in advance.

@bugy
Copy link
Owner Author

bugy commented Aug 31, 2020

Hi @kbza, I'm afraid it's not possible at the moment, but would be more or less straightforward to implement. Do you want to try and submit a PR?

@kbza
Copy link

kbza commented Aug 31, 2020

I don't think I'm confident enough... Many years as a sysadmin only making just some bash scripts, so my coding skills are a bit rusty. Also, I've never done any serious project with python. Nonetheless, I'm gonna give it a try, but I would like you to consider a "plan B" :P.

Anyway, which one of the two last options do you think is the best? I'm thinking more of a "chain" of includes as a better way of structuring... but, on the other hand, the array way could work with multiselect or script/command that finds more than one config file matching a pattern ("script": "ls /path/to/web*_server.json" -> will include web1_server.json, web2_server.json... )

@bugy
Copy link
Owner Author

bugy commented Aug 31, 2020 via email

@kbza
Copy link

kbza commented Aug 31, 2020

This is more or less what I have atm:

{
  "name": "Param Test",
  "script_path": "./scripts/paramTest.sh",
  "include": "./platform_files/${Server Select}",
  "parameters": [
    {
      "name": "Server Type",
      "type": "multiselect",
      "values": [ "app", "db", "web", "lts" ],
      "separator": "|"
    },
    {
      "name": "Server Select",
      "type": "multiselect",
      "values": { "script": "find ./platform_files/ -regex '.*[${Server Type}]+[0-9]+_server.json' -type f -printf \"%f\n\" "}
    }
  ]
}

but only accepts one include file. So something like:

{
  "name": "Param Test",
  "script_path": "./scripts/paramTest.sh",
  "include": [ ${Server Select} ]
  "parameters": [
    {
      "name": "Server Type",
      "type": "multiselect",
      "values": [ "app", "db", "web", "lts" ],
      "separator": "|"
    },
    {
      "name": "Server Select",
      "type": "multiselect",
      "values": { "script": "find ./platform_files/ -regex '.*[${Server Type}]+[0-9]+_server.json' -type f -printf \" \"%f\"\n\" "}
      "separator": ","
    }
  ]
}

Could work with arrays.

@bugy
Copy link
Owner Author

bugy commented Sep 1, 2020 via email

@kbza
Copy link

kbza commented Sep 1, 2020

Exactly, that will be possible when include directive accepts an array of values/files. I think this is the easiest aproach, though atm, I have no clue how to do it.

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

No branches or pull requests

3 participants