When the configure script runs when a user does a snap set
, is there any way to retrieve the previous value of the key in order to compare the old and new values? If not, is there a recommended way to save the key value upon it being validated in the configure script?
Your best bet would be to store a copy of each value with a private prefix in the configure hook, so when the configure hook runs you can compare the private old value, to the new value.
Thanks for the reply. I currently do something like you propose, except that the config option is not private, in that it’s discoverable via snap get mysnap -l
. I’m not sure I understand what you mean by ‘private prefix’. Is there some special prefix you can add to a config option that keeps it from being discoverable?
No, sadly you can’t hide them.
I meant prefix them with ‘private’ so users potentially know that they shouldn’t touch those settings, but it’s not foolproof…
You could also write them to a file on disk, that way they are not exposed to the configuration?
Ok, thanks, I thought I was missing something about the private prefix:grinning:
Yeah, I thought about the file too and may just go that route.