Skip to content

Commit

Permalink
Use semver.org regex for publishedVersion validation (#426)
Browse files Browse the repository at this point in the history
* Use semver.org regex

* Add line breaks to regex declaration
  • Loading branch information
eshiroma authored Nov 6, 2019
1 parent 938918b commit b2c3337
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion marketplace/deployer_util/config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import yaml

NAME_RE = re.compile(r'[a-zA-z0-9_\.\-]+$')
SEMVER_RE = re.compile(r'^[0-9]+\.[0-9]+\.([^.]+)$')
# Suggested from https://semver.org
SEMVER_RE = re.compile(r'^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)'
'(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)'
'(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?'
'(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')

XGOOGLE = 'x-google-marketplace'
XTYPE_NAME = 'NAME'
Expand Down
5 changes: 3 additions & 2 deletions marketplace/deployer_util/config_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def test_v2_fields(self):
applicationApiVersion: v1beta1
publishedVersion: 6.5.130
publishedVersion: 6.5.130-metadata
publishedVersionMetadata:
releaseNote: Bug fixes
releaseTypes:
Expand Down Expand Up @@ -718,7 +718,8 @@ def test_v2_fields(self):
self.assertTrue(schema.x_google_marketplace.is_v2())
self.assertEqual(schema.x_google_marketplace.app_api_version, 'v1beta1')

self.assertEqual(schema.x_google_marketplace.published_version, '6.5.130')
self.assertEqual(schema.x_google_marketplace.published_version,
'6.5.130-metadata')
version_meta = schema.x_google_marketplace.published_version_meta
self.assertEqual(version_meta.release_note, 'Bug fixes')
self.assertListEqual(version_meta.release_types, ['BUG_FIX'])
Expand Down

0 comments on commit b2c3337

Please sign in to comment.