[Fix gate] Fix ValueError being thrown if sub path starts with $
This PS fixes ValueError being thrown by jsonpath_replace if the substitution path begins with '$' which is allowed for jsonpath_ng to do a replacement. Example error: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/deckhand/engine/secrets_manager.py", line 212, in substitute_all document['data'], src_secret, dest_path, dest_pattern) File "/usr/local/lib/python3.6/site-packages/deckhand/utils.py", line 154, in jsonpath_replace jsonpath) ValueError: ('The provided jsonpath %s does not begin with "."', '$.values.secrets.tls.ca') Change-Id: I4485fd6d82d27498b853a75341069b6dc3c9b62a Ref: http://12.37.173.196:32775/repository/att-comdev-jenkins-logs/att-comdev/armada/268/armada-268
This commit is contained in:
parent
d0a42cfc7a
commit
af6c2ea8ee
|
@ -148,10 +148,12 @@ def jsonpath_replace(data, value, jsonpath, pattern=None):
|
|||
jsonpath = '$'
|
||||
elif jsonpath.startswith('.'):
|
||||
jsonpath = '$' + jsonpath
|
||||
else:
|
||||
LOG.error('The provided jsonpath %s does not begin with "."', jsonpath)
|
||||
raise ValueError('The provided jsonpath %s does not begin with "."',
|
||||
jsonpath)
|
||||
|
||||
if not jsonpath == '$' and not jsonpath.startswith('$.'):
|
||||
LOG.error('The provided jsonpath %s does not begin with "." or "$"',
|
||||
jsonpath)
|
||||
raise ValueError('The provided jsonpath %s does not begin with "." '
|
||||
'or "$"' % jsonpath)
|
||||
|
||||
def _do_replace():
|
||||
p = jsonpath_ng.parse(jsonpath)
|
||||
|
|
Loading…
Reference in New Issue