Skip to content

Latest commit

 

History

History
83 lines (65 loc) · 3.23 KB

default-tracks.org

File metadata and controls

83 lines (65 loc) · 3.23 KB

Default Tracks

Scope

Allow for operations relevant to default tracks using the Snapcraft command line.

The new commands introduced shall allow for viewing tracks and their corresponding status as well as setting a track as a default one.

User Experience

Viewing Tracks

A new command shall be introduced, snapcraft list-tracks with an alias of tracks. The command shall display the list of available tracks with potential status values of active, hidden and closed. When a default track is set, the status shall be set to default which will implicitly mean it is active.

The command shall be defined as:

snapcraft track|list-tracks <snap-name>

With that criteria, this is how the output shall display for a given snap:

$ snapcraft list-tracks node
Track    Status    Creation-Date         Version-Pattern
17       active    2020-08-26T12:13:43Z  17.*
16       default   2020-07-26T12:13:43Z  -
15       active    2020-07-26T12:13:43Z  -
14       hidden    2020-06-26T12:13:43Z  -
13       closed    2020-05-26T12:13:43Z  -

Setting a default track

Setting a default track shall have an explicit command to do so.

$ snapcraft set-default-track <snap-name> <track>

When setting a valid track, this is what the command shall output:

$ snapcraft set-default-track node 17
Default track for 'node' set to '17'.

If the track is not valid, the output shall follow the convention used in the SnapcraftException class as defined in snapcraft.internal.errors. With that in mind, the following shall be displayed when an unknown track is specified:

$ snapcraft set-default-track node 18
The specified track does not exist for 'node'.

Recommended resolution:
Run 'snapcraft list-tracks' to see the available tracks.

For more information, checkout:
https://snapcraft.io/docs/release-management

Implementation

Snap Store API

Snap Store APIs already exist to implement setting a default track to a given track. This is provided by the /metadata endpoint documented as part of the V1 Snap Store API Managing Snap Metadata.

Displaying of track information shall be resolved by the channel-map endpoint defined in the V2 Snap Store API Snap Channel Map.

For this first implementation the default track shall be retrieved from the snap.default-track field. In the future, the Snap Channel Map endpoint shall add a status field for a track list item which shall return: active, hidden and closed. In this current implementation, the Snapcraft logic shall query for this field and set a fallback value of active when the status field is not found. The Created information shall be retrieved from the creation-date field for a track list item from the Snap Store API endpoint.

Use of the API shall be mediated by implementation following the code style used in snapcraft.storeapi.