diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2017-01-09 22:14:08 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2017-01-10 20:53:20 +0300 |
commit | 3a51d190397c1bd52edbc23daf793f4efcec4657 (patch) | |
tree | 402c5fde96a11bb51644245a7b06761c50bd0c3b | |
parent | ef6598cec3c9e98eaa0030a0d33c8ec3ef68d6f0 (diff) |
Fix keep: implementation
Actually permit the key in override.hint
Warn if we specify a non-existent version to keep
-rwxr-xr-x | calm/hint.py | 3 | ||||
-rwxr-xr-x | calm/package.py | 5 | ||||
-rw-r--r-- | test/testdata/hints/x86/release/invalid/expected | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/calm/hint.py b/calm/hint.py index 7eb41bd..5a36901 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -63,6 +63,7 @@ versionkeys = { } overridekeys = { + 'keep': 'val', 'keep-count': 'val', 'keep-days': 'val', } @@ -221,7 +222,7 @@ def hint_file_parse(fn, kind): value = match.group(2) if key not in hintkeys[kind]: - errors.append('unknown setup key %s at line %d' % (key, i)) + errors.append('unknown key %s at line %d' % (key, i)) continue type = hintkeys[kind][key] diff --git a/calm/package.py b/calm/package.py index cf3c22e..a40105d 100755 --- a/calm/package.py +++ b/calm/package.py @@ -924,7 +924,10 @@ def stale_packages(packages): # mark any versions explicitly listed in the keep: override hint for v in po.override_hints.get('keep', '').split(): - mark_package_fresh(packages, pn, v) + if v in po.vermap: + mark_package_fresh(packages, pn, v) + else: + logging.error("package '%s' has non-existent keep: version '%s'" % (pn, v)) # mark as fresh the highest n versions, where n is given by the # keep-count: override hint, (defaulting to DEFAULT_KEEP_COUNT) diff --git a/test/testdata/hints/x86/release/invalid/expected b/test/testdata/hints/x86/release/invalid/expected index 95681a8..ebcffb4 100644 --- a/test/testdata/hints/x86/release/invalid/expected +++ b/test/testdata/hints/x86/release/invalid/expected @@ -1,4 +1,4 @@ -{'parse-errors': ['unknown setup key unknown-key at line 0', +{'parse-errors': ['unknown key unknown-key at line 0', "unknown setup construct 'invalid-construct' at line 1", "required key 'category' missing", "required key 'sdesc' missing"]} |