Basic labels support

Adds basic labels support to the registry code (V2), and the API. Note that this does not yet add any UI related support.
This commit is contained in:
Joseph Schorr 2016-07-18 18:20:00 -04:00
parent 427070b453
commit 608ffd9663
24 changed files with 907 additions and 36 deletions

44
test/test_validation.py Normal file
View file

@ -0,0 +1,44 @@
import unittest
from util.validation import validate_label_key
class TestLabelKeyValidation(unittest.TestCase):
def assertValidKey(self, key):
self.assertTrue(validate_label_key(key))
def assertInvalidKey(self, key):
self.assertFalse(validate_label_key(key))
def test_basic_keys(self):
self.assertValidKey('foo')
self.assertValidKey('bar')
self.assertValidKey('foo1')
self.assertValidKey('bar2')
self.assertValidKey('1')
self.assertValidKey('12')
self.assertValidKey('123')
self.assertValidKey('1234')
self.assertValidKey('git-sha')
self.assertValidKey('com.coreos.something')
self.assertValidKey('io.quay.git-sha')
def test_invalid_keys(self):
self.assertInvalidKey('')
self.assertInvalidKey('git_sha')
def test_must_start_with_alphanumeric(self):
self.assertInvalidKey('-125')
self.assertInvalidKey('-foo')
self.assertInvalidKey('foo-')
self.assertInvalidKey('123-')
def test_no_double_dashesdots(self):
self.assertInvalidKey('foo--bar')
self.assertInvalidKey('foo..bar')
if __name__ == '__main__':
unittest.main()