Skip to content

Commit

Permalink
Support MASKED_FIELD x-google-marketplace type (#408)
Browse files Browse the repository at this point in the history
* Support MASKED_FIELD x-google-marketplace type

* Remove trailing comma for consistency
  • Loading branch information
eshiroma authored Oct 1, 2019
1 parent 028d422 commit dee611d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion marketplace/deployer_util/config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
XTYPE_ISTIO_ENABLED = 'ISTIO_ENABLED'
XTYPE_INGRESS_AVAILABLE = 'INGRESS_AVAILABLE'
XTYPE_TLS_CERTIFICATE = 'TLS_CERTIFICATE'
XTYPE_MASKED_FIELD = 'MASKED_FIELD'

WIDGET_TYPES = ['help']

Expand Down Expand Up @@ -520,7 +521,8 @@ def __init__(self, name, dictionary, required):
xt = _must_get(self._x, 'type',
'Property {} has {} without a type'.format(name, XGOOGLE))

if xt in (XTYPE_NAME, XTYPE_NAMESPACE, XTYPE_DEPLOYER_IMAGE):
if xt in (XTYPE_NAME, XTYPE_NAMESPACE, XTYPE_DEPLOYER_IMAGE,
XTYPE_MASKED_FIELD):
_property_must_have_type(self, str)
elif xt in (XTYPE_ISTIO_ENABLED, XTYPE_INGRESS_AVAILABLE):
_property_must_have_type(self, bool)
Expand Down
9 changes: 8 additions & 1 deletion marketplace/deployer_util/config_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
generatedProperties:
base64EncodedPrivateKey: keyEncoded
base64EncodedCertificate: crtEncoded
customSecret:
title: Secret needed by the app.
description: User-entered text to be masked in the UI.
type: string
x-google-marketplace:
type: MASKED_FIELD
required:
- propertyString
- propertyPassword
Expand Down Expand Up @@ -129,7 +135,7 @@ def test_types_and_defaults(self):
'propertyNumberWithDefault', 'propertyBoolean',
'propertyBooleanWithDefault', 'propertyImage',
'propertyDeployerImage', 'propertyPassword', 'applicationUid',
'istioEnabled', 'ingressAvailable', 'certificate'
'istioEnabled', 'ingressAvailable', 'certificate', 'customSecret'
}, set(schema.properties))
self.assertEqual(str, schema.properties['propertyString'].type)
self.assertIsNone(schema.properties['propertyString'].default)
Expand Down Expand Up @@ -173,6 +179,7 @@ def test_types_and_defaults(self):
schema.properties['ingressAvailable'].xtype)
self.assertEqual(str, schema.properties['certificate'].type)
self.assertEqual('TLS_CERTIFICATE', schema.properties['certificate'].xtype)
self.assertEqual('MASKED_FIELD', schema.properties['customSecret'].xtype)

def test_invalid_names(self):
self.assertRaises(
Expand Down

0 comments on commit dee611d

Please sign in to comment.