-
Notifications
You must be signed in to change notification settings - Fork 138
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
Rockons: Ability to set environment objects as optional #2094
Comments
This issue should be considered in conjunction with the issue #2012 (add env default option for rockons) for defining default values for the environment object. |
Adding another forum thread requesting this feature: |
While looking at this again, wanted to reported my observations, ideas: Possibly add another field to the model in
In the
Of course, since that form is shared with the custom control (for OwnCloud, etc.), would have to see whether that will be a conflict. Finally, I don't know (since I am not a js or handlebars expert) how the validation needs to change to differentiate between optional and required fields in the rockstor-core/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js Lines 774 to 785 in 3ad7eee
Also, if optional environment variables are not filled in (i.e. not request/used) those entries would not be saved into the database, or would they? |
@Hooverdan96 Great to see some progress on this one by the way.
Each db record must be consistent so it's constituent fields must contain something, default null if null=True for example. Pretty sure I've not picked up your point here however. Also js is not my favourite and I really don't like the kind of code that almost always seems to be associated with it (that would be a digression) :) . I think @FroggyFlox may be of more help on this one, although he is busy elsewhere it seems. I think ultimately the proof is in the pudding as it were. Go ahead and implement your idea in a draft pr and take a look at exactly what actually happens in the database. That is the true of the matter and will likely uncover other knock-on effects that are not always easy to predict (at least for me). I'm really trying to avoid 'hard' db field additions currently (i.e. not just properties) as we are so close the next stable release, but given #2529 there may soon be the option to pop this into the next testing channel where a db addition is more than welcome. |
Very briefly as I can't remember the details exactly and I can't look at it right now but: If I remember correctly, the requirement we have is purely on the frontend side (js validation) as I think we have all of those fields set to null=True in their respective models. Sorry again for the excessive briefness here; I'll try to have a better look some time later. |
Thanks both. @phillxnet I was thinking about the saving in the object, and how it would look like in the installation summary page (i.e. all non-maintained optional fields would also show up, or only the ones for which values had been entered) - but @FroggyFlox comment brings back that when one doesn't maintain a device entry, it will also show up in the summary page. So, we would still see a long list of environment entries (like in the Unpackerr Rockon example from another thread), but they would show empty values. Which, I think is fine, especially if it doesn't require major changes to the way entries are stored, etc. As for the js piece, I think if for this topic we used a different approach - reducing reliance on js further - then we would want to eventually propagate this for all objects, too (if feasible), which is probably a "slightly" bigger undertaking (and definitely only after stable release). So, it might be easier to follow a similar approach as for the other objects that relies on some js logic interaction to be consistent, and then contemplate a wholesale move to another approach later? As for the adding of new fields to the database, I didn't expect that this type of a change would make it in before the stable release to avoid another variable that could further delay it. If I have time, I might try a PoC, since, as you said, the proof will be in the pudding :). But certainly interested if @FroggyFlox has some more insights to consider (though, no rush, I know you're busy on many fronts, of which Rockstor is only one). |
Good stuff.
Do you mean here, that if they entered a value in an optional field and then subsequently decide not to use it, they can essentially disable the usage of that value by setting the check mark?
|
That's correct. The checkbox itself is represented by its own boolean in the model. If a default value has been defined in the JSON, then the default value will be shown. User value obviously replaces/overrides the default value. Do I need to save the default value to DB, or should I just read it from the JSON? I could still pass it to Handlebars, if it isn't in the model, right? |
@FroggyFlox probably has to answer that, since he's intimately familiar (and designer of the most recent architectural changes) of that. |
@kanecko, awesome to see you working on this, thank you! At first look, I think you may not even need to add anything to the model, but just how Rockstor parses and deals with what the is given to it. The docker devices are optional that wat, for instance. I'm unfortunately unable to have a proper look at this right now but will try to give a better answer with examples as soon as possible. Thank you so much! |
Thanks for the visual.
Would that be the planned behavior? Thinking about the use cases in my mind:
Optional Parameter:
|
When the checkbox is checked, the variable will not be defined at the run command. Maybe it's better UX if I replace the text field with a "variable will not be defined" instead? Another thing to consider is the "index" attribute in JSON and how should it play together with optional/required fields. When no index attr is defined on any of the env vars: place required vars at the top, optional below the required. |
A little bit too wide for my taste, but at least it conveys more meaning than just a checkbox. I am having trouble finding the right words to put on the button. So any help here is appreciated. But it can wait until the code-review stage. |
Inactive/Active maybe? single button might be nicer, as you've said, needing less space ... Or stick with the checkbox but have it as a column with the header of "Inactive"? All required items would not have one obviously.... @FroggyFlox if you do get a minute to chime in, since you also had a vision on how this can be communicated/handled. |
@kanecko , @Hooverdan96 , thank you so much for all your work there, that's awesome! I indeed would like to chime in here but I unfortunately do not have the time at this very moment to clearly communicate what I have in mind; I'll do my best to take the time to do so shortly, however. My sincere apologies for that :-( |
The code changes of the prototype so far: https://github.com/kanecko/rockstor-core |
this is out of the discussion in this thread:
https://forum.rockstor.com/t/default-values-for-environment-variables-in-rockon-definition/6512
Currently environment variables are required, i.e. if they are defined as part of the json file, then during the installation/configuration of the RockOn, they have to be populated. Especially for Rockons based on docker images that use environment variables to pass specific options to the API of the image application, this would be useful.
@FroggyFlox already has mentioned an idea on how to represent this in the json file:
simple key:value under the specific environment object to set an "optional": true/false flag.
Behavior when the json file is ingested:
If set to true, the given environment variable can be left blank during the rock-on install wizard. And if it's left blank it will not be part of the docker run command that is generated to launch the RockOn.
In order to keep backwards compatibility, if this key:value pair doesn't exist (or is set to false), the original behavior of requiring to maintain the environment object during the install wizard.
The text was updated successfully, but these errors were encountered: