Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling when setting up environment statements #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pulsar/managers/util/env.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

RAW_VALUE_BY_DEFAULT = False
VALID_ENV_OPTIONS = ('file', 'execute', 'name/value')


def env_to_statement(env):
Expand Down Expand Up @@ -28,9 +29,11 @@ def env_to_statement(env):
execute = env.get('execute', None)
if execute:
return execute
name = env['name']
value = __escape(env['value'], env)
return '%s=%s; export %s' % (name, value, name)
name = env.get('name', None)
if name:
value = __escape(str(env['value']), env)
return '%s=%s; export %s' % (name, value, name)
raise RuntimeError("Invalid env definition, must be one of %s: %s" % (str(VALID_ENV_OPTIONS), str(env)))


def __escape(value, env):
Expand Down