How to unset snap config?

What’s the best/proper way to unset a snap config?

I’ve been telling people to do it by setting to null, e.g. snap set kube-apiserver runtime-config=null, since that worked for me in the past. I haven’t seen any documentation around it though. Is that the right way to do it?

1 Like

There is currently no way to remove configuration values, that’s clearly an omission on our side and we will fix it. You can set it to null or empty string, but you cannot get rid of the value.

Having said that, setting it to null exposed a bug: https://bugs.launchpad.net/snapd/+bug/1699768 (I know you are are aware of the bug, just mentioning it for everyone else following the topic) and the proposed fix is here: https://github.com/snapcore/snapd/pull/3541

We will address the problem of removing unwanted config keys separately (details to be decided).

3 Likes

Resurrecting the old topic, just to give quick update on this; adding an ability to unset snap config is currently on our roadmap and per discussion from last sprint, we’re going to add two ways for unsetting:

  • snap unset (e.g. snap unset core http.proxy)
  • snap set k=v k! (k! will unset key, e.g. snap set core proxy.http=foo proxy.https!)

The second syntax will allow setting and unsetting configuration keys in one go, as part of same transaction.

2 Likes

Is this available yet?

Not yet, while the CLI aspects are settled, there are some other aspects that we realized and @pedronis will soon write about them here on the forum to gather feedback.

The discussion about the way forward in terms of API is here: