Would it be useful to add more "default" properties to snapcraft.json?

For reasons best kept to myself, I’ve been poring over the snapcraft schema in snapcraft.json, and noticed a number of properties that would seem to be appropriate for defining a default value, things like refresh-mode and install-mode and lots of others whose values are defined via an “enum”. I suspect that, lacking a default value in the schema, a default is eventually selected later in some way, but having that in the schema would make such defaults more obvious.

Does this make sense, or am I way off-base?

rday

Hi,

The snapcraft.json schema is for snapcraft.yaml itself. The default would be for a value applied to snapcraft.yaml and the eventual snap.yaml. There is no default as nothing is written, omission of a value just goes down snapd runtime defaults.

OK, let me ask what might be a silly question, as I think I see what is happening here, but I am willing to be corrected.

Yes, I know snapcraft.json defines the schema for a snapcraft.yaml and, based on the schema, there are certain meta-data fields that are clearly required, such as summary, description, version, etc., and if you omit such fields, snapcraft will complain. For such fields, you wouldn’t define a “default” value in the schema as the developer can put in there whatever they want; all the schema says is that you must define that property or you’re toast.

On the other hand, meta-data that accepts a fixed set of values can (of course) have a default value:

    "confinement": {
        "type": "string",
        "description": "the type of confinement supported by the snap",
        "default": "strict",

so you have the freedom to not define the confinement level, whereupon you will see:

'confinement' property not specified: defaulting to 'strict'

Now, in the schema, “confinement” is not defined as a “required” property, but is it the case that by simply assigning it a default value, it is implicitly required? The same can be said for the snap “grade”: it’s not categorized as required but, since it’s defined as taking a default value of “stable”, it is effectively required? And so on, and so on.

confinement and grade are two examples that happen to be there due to historical reasons.

Build time defaults (snapcraft) could eventually put us in a corner with regards to runtime defaults (snapd) which is what we do not want.