Skip to content

Commit d317b5b

Browse files
committed
ID-53: support JSON boolean values for properties
1 parent db1dd62 commit d317b5b

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

CHANGELOG.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
[cols="1,2,<10a", options="header"]
55
|===
66
|ID|Type|Description
7+
|https://github.com/Axway-API-Management-Plus/apigw-maven-plugin/pull/53[#53]
8+
|Enhancement
9+
|The property configuration now supports JSON boolean values.
10+
11+
[source,json]
12+
----
13+
{
14+
"properties": {
15+
"enables": false <1>
16+
}
17+
}
18+
----
19+
<1> Boolean values are now supported
20+
721
|https://github.com/Axway-API-Management-Plus/apigw-maven-plugin/issues/52[#52]
822
|Bug
923
|In case the entity field configuration file doesn't exist the following error occurs:

src/main/resources/scripts/lib/envconfig.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ def __get_property(self, p):
121121
if self.__properties:
122122
v = self.__properties.get_property(p)
123123

124-
if not v:
124+
if v is None:
125125
if "properties" in self.__config_json and p in self.__config_json["properties"]:
126126
v = self.__config_json["properties"][p]
127+
128+
if v is not None and type(v) is bool:
129+
v = "true" if v else "false"
130+
127131
return v
128132

129133
def __reset(self):
@@ -184,7 +188,7 @@ def get_value(self, entity, entity_field):
184188
if f["value"]:
185189
p = f["value"]
186190
value = self.__get_property(p)
187-
if not value:
191+
if value is None:
188192
raise ValueError("Missing configured property '%s'" % (p))
189193
elif "value" == f["source"]:
190194
value = f["value"]
@@ -198,7 +202,7 @@ def get_value(self, entity, entity_field):
198202
if f["value"]:
199203
c = f["value"]
200204
value = self.__secrets.get_secret(c)
201-
if not value:
205+
if value is None:
202206
raise ValueError("Missing configured secret '%s'" % (c))
203207
else:
204208
raise ValueError("Invalid source property '%s'" % f["source"])
@@ -336,9 +340,13 @@ def __get_property(self, p):
336340
if self.__properties:
337341
v = self.__properties.get_property(p)
338342

339-
if not v:
343+
if v is None:
340344
if "properties" in self.__config_json and p in self.__config_json["properties"]:
341345
v = self.__config_json["properties"][p]
346+
347+
if v is not None and type(v) is bool:
348+
v = "true" if v else "false"
349+
342350
return v
343351

344352
def set_cert_infos(self, cert_infos):
@@ -397,7 +405,7 @@ def get_certificates(self):
397405
if "property" == cert["source"]:
398406
p = cert["password"]
399407
password = self.__get_property(p)
400-
if not password:
408+
if password is None:
401409
raise ValueError("Missing configured property '%s' for alias '%s'!" % (p, alias))
402410
elif "password" == cert["source"]:
403411
password = cert["password"]
@@ -410,7 +418,7 @@ def get_certificates(self):
410418

411419
c = cert["password"]
412420
password = self.__secrets.get_secret(c)
413-
if not password:
421+
if password is None:
414422
raise ValueError("Missing configured secret '%s' for alias '%s'!" % (c, alias))
415423
else:
416424
raise ValueError("Invalid password source '%s' for alias '%s'!" % (cert["source"], alias))

0 commit comments

Comments
 (0)