Skip to content

Commit 3a4bf37

Browse files
authored
RD-6368 Handle JSON in secrets update (#1451)
1 parent 7e037ec commit 3a4bf37

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

cloudify_cli/commands/secrets.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,19 @@ def update(key,
262262
"""
263263
utils.explicit_tenant_name_message(tenant_name, logger)
264264
validate_visibility(visibility)
265-
secret_string = _get_secret_string(secret_file, secret_string)
265+
value = _get_secret_string(secret_file, secret_string)
266266
graceful_msg = 'Requested secret with key `{0}` was not found'.format(key)
267267
with handle_client_error(404, graceful_msg, logger):
268-
client.secrets.update(key, secret_string, visibility, hidden_value)
268+
secret_details = client.secrets.get(key)
269+
if secret_details.schema:
270+
try:
271+
value = json.loads(value)
272+
except json.decoder.JSONDecodeError:
273+
raise CloudifyCliError(
274+
f'Error decoding secret value: \'{value}\' is not of '
275+
f'type \'{secret_details.schema.get("type")}\'')
276+
277+
client.secrets.update(key, value, visibility, hidden_value)
269278
logger.info('Secret `{0}` updated'.format(key))
270279

271280

0 commit comments

Comments
 (0)