-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dconf_module: add feature: populate a subpath from file #10432
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
base: main
Are you sure you want to change the base?
Conversation
* Simplify check of changes
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Co-authored-by: Felix Fontein <felix@fontein.de>
This comment was marked as outdated.
This comment was marked as outdated.
* Mutual exclusion of 'path' and 'value'
plugins/modules/dconf.py
Outdated
# NOTE: This case shouldn't happen yet as 'key' and 'path' are | ||
# required with 'state=present' | ||
# TODO: if 'key' ends with '/' then 'dconf list' should be used | ||
# else, 'dconf read' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this TODO be part of dconf.load()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't thing so.
The architecture defined by the original author suggests that:
dconf.read
handlesdconf read [key]
dconf.write
handlesdconf write [key] [value]
dconf.load
handlesdconf load [key] < [path]
(this contribution)
If key
ends with '/', it means that it's a directory. If value
is set, it should be illegal. If path
is set, we're in the case of the contribution. If none of them is set, user tries to read a directory. It cannot be handled neither by dconf read
nor dconf dump
instead, dconf list
must be used. In the future, dconf.list
must be created to by compliant.
As you said, state=read
is a mistake. As I understand, it means that reading key
(whatever the meaning - a key or a directory) should have been handled by state=present
. That's why I added this TODO here.
Are you agree with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said,
state=read
is a mistake. As I understand, it means that readingkey
(whatever the meaning - a key or a directory) should have been handled bystate=present
. That's why I added this TODO here.
What do you mean that read is a mistake? The read
state is meant to read the key value without making changes to it - the present
state will/might change the value. Or have I misunderstood something here?
|
||
# Run the command and fetch standard return code, stdout, and stderr. | ||
dbus_wrapper = DBusWrapper(self.module) | ||
rc, out, err = dbus_wrapper.run_command(command, data=raw_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to keys that already exist, but are not part of raw_config
? Are these kept, or removed?
If the latter, the changed
check above is not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If keys exist in the database but, are not part of raw_config
then they're kept. changed
check should be correct!
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
This update allows: * Compatibility between python2 and python3 * To handle IO operation errors Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Note that I added a sub-function ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @Sh3idan, thanks for your contribution.
I have some other comments as well.
plugins/modules/dconf.py
Outdated
@@ -61,10 +61,17 @@ | |||
description: | |||
- Value to set for the specified dconf key. Value should be specified in GVariant format. Due to complexity of this | |||
format, it is best to have a look at existing values in the dconf database. | |||
- Required for O(state=present). | |||
- Required for O(state=present). If provided, O(path) is not required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I may suggest:
- Required for O(state=present). If provided, O(path) is not required. | |
- O(path) and O(value) are mutually exclusive, but one of them is required when O(state=present). |
Same text in path
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your comment is outdated. Please, tell me if the Felix's suggestions are correct. If not, I'll updated them.
plugins/modules/dconf.py
Outdated
changed = any( | ||
not self.variants_are_equal(self.read("%s%s/%s" % (root_dir, sub_dir, k)), v) | ||
for sub_dir in config.sections() | ||
for k, v in config[sub_dir].items() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I presume you are doing this because dconf
will not report whether any value was changed, is that so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's why i'm doing this. Should I also check if the keys have actually been added?
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
* Remove unreachable code
SUMMARY
This merge request allows to populate a subpath from file by using
load
sub-command of thedconf
binary. Below the changes that were made:state: load
has been added to address the featurepath
is a new option working with the feature. It points to a file located in node which contains a subpath dump.key
remains unchanged but, here, it refers to a root directory (instead of a dconf key) and must be '/' terminatedISSUE TYPE
COMPONENT NAME
dconf
ADDITIONAL INFORMATION
Below a role using the newly
load
state, followed by the varbatim output:The content of the
path
file is: