in lambda-helpers/semver-handler/lambda.py [0:0]
def get_user_params(job_data):
"""Decodes the JSON user parameters and validates the required properties.
Args:
job_data: The job data structure containing the UserParameters string which should be a valid JSON structure
Returns:
The JSON parameters decoded as a dictionary.
Raises:
Exception: The JSON can't be decoded or a property is missing.
"""
try:
# Get the user parameters which contain the stack, artifact and file settings
user_parameters = job_data['actionConfiguration']['configuration']['UserParameters']
decoded_parameters = json.loads(user_parameters)
except Exception as e:
# We're expecting the user parameters to be encoded as JSON
# so we can pass multiple values. If the JSON can't be decoded
# then fail the job with a helpful message.
raise Exception('UserParameters could not be decoded as JSON')
if 'repo' not in decoded_parameters:
# Validate that the repo is provided, otherwise fail the job
# with a helpful message.
raise Exception('Your UserParameters JSON must include the repo name')
if 'branch' not in decoded_parameters:
# Validate that the repo is provided, otherwise fail the job
# with a helpful message.
raise Exception('Your UserParameters JSON must include the branch')
return decoded_parameters