Add support for epoch property. #502

Merged
merged 11 commits into from May 24, 2016

Conversation

Projects
None yet
4 participants
Member

kyrofa commented May 12, 2016

In order to support step upgrades, snaps need to be able to specify upgrade paths. This PR resolves LP: #1581113 by implementing that via a new "epoch" property specified in the snap.yaml. Valid epochs are positive integers (e.g. 0, 1, etc.) or positive integers followed by an asterisk (e.g. 1*, 2*, etc.).

0 is epoch 0; 1* is the upgrade path from 0 to 1; 1 is epoch 1 (and so on).

Add support for epoch property.
In order to support step upgrades, snaps need to be able to specify
upgrade paths. That's done in this commit via a new "epoch" property
specified in the `snap.yaml`. Valid epochs are positive integers (e.g.
0, 1, etc.) or positive integers followed by an asterisk (e.g. 1*, 2*,
etc.).

0 is epoch 0; 1* is the upgrade path from 0 to 1; 1 is epoch 1 (and so
on).

LP: #1581113

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
snapcraft/tests/test_yaml.py
+ '1*',
+ 1,
+ '400*',
+ 1234,
@elopio

elopio May 12, 2016

Member

what about '00001', valid or invalid?

@kyrofa

kyrofa May 12, 2016

Member

Valid since YAML will parse it as 1, but difficult to test as 0001 isn't a valid number in Python.

@sergiusens

sergiusens May 23, 2016

Collaborator

00001 could be an integration test, but I fear we would be then testing the yaml parser instead 😉

@sergiusens

sergiusens May 23, 2016

Collaborator

how about '00001'? Is that valid? I am asking without having looked at how this is spec'ed

@kyrofa

kyrofa May 23, 2016

Member

You mean the string "00001"? That's rejected, to avoid having to validate the number separately from the asterisk in the string. I've updated the tests quite a bit, adding both a test for 01 and "01".

Member

elopio commented May 12, 2016

I'm +1, with one question. Also, please update docs/snapcraft-syntax.md

docs/snapcraft-syntax.md: Document "epoch" property.
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Member

kyrofa commented May 12, 2016

Also, please update docs/snapcraft-syntax.md

Good catch, thanks-- done.

kyrofa and others added some commits May 18, 2016

"0" is a valid epoch. 1.2 is not.
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Collaborator

sergiusens commented May 24, 2016

you can make this always a string by implementing JSONDecoder so it loads as a str straight up

Member

kyrofa commented May 24, 2016

you can make this always a string by implementing JSONDecoder so it loads as a str straight up.

I've instead updated this to validate with a custom format, where I validate via strings only and can provide a nicer-looking error message. Let me know what you think.

snapcraft/tests/test_yaml.py
+ self.assertRegex(
+ raised.exception.message,
+ "The 'epoch' property does not match the required "
+ "schema:.*is not a 'epoch' \(epochs are positive integers "
@sergiusens

sergiusens May 24, 2016

Collaborator

an epoch?

@kyrofa

kyrofa May 24, 2016

Member

It's actually hard-coded in jsonschema to 'is not a'. Terrible, eh? But I wanted to use the format checkers the way they intended...

@kyrofa

kyrofa May 24, 2016

Member

I'm thinking about contributing 'is not a valid' upstream.

kyrofa added some commits May 24, 2016

Stop validating epoch as a number and a string-- use only string.
This is done via  custom validator format ('epoch').

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Collaborator

sergiusens commented May 24, 2016

retest this please 😢

Collaborator

sergiusens commented May 24, 2016

retest this please

Member

elopio commented May 24, 2016

Both tests passed, but jenkins failed to communicate the result back to github.
I'm merging.

@elopio elopio merged commit a3a4728 into snapcore:master May 24, 2016

2 of 4 checks passed

Examples tests Started
Details
autopkgtest Started
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.01%) to 96.311%
Details

@kyrofa kyrofa deleted the kyrofa:feature/1581113/epoch_property branch May 24, 2016

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

Add support for epoch property. (#502)
In order to support step upgrades, snaps need to be able to specify
upgrade paths. That's done in this commit via a new "epoch" property
specified in the `snap.yaml`. Valid epochs are positive integers (e.g.
0, 1, etc.) or positive integers followed by an asterisk (e.g. 1*, 2*,
etc.).

0 is epoch 0; 1* is the upgrade path from 0 to 1; 1 is epoch 1 (and so
on).

LP: #1581113

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment