Skip to content

Commit

Permalink
[DC] Added list type and int casting to runner (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuannie1 authored and sfc-gh-afedorov committed Sep 18, 2019
1 parent cd85b6c commit f08cf87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/runners/connectors_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ def connection_run(connection_table):
name = module_option['name']
if module_option.get('secret') and name in options:
options[name] = vault.decrypt_if_encrypted(options[name])
if module_option.get('type') == 'json':
options[name] = json.loads(options[name])
if module_option.get('type') == 'int':
options[name] = int(options[name])
if module_option.get('type') == 'json':
options[name] = json.loads(options[name])
if module_option.get('type') == 'list':
options[name] = options[name].split(',')
if module_option.get('type') == 'int':
options[name] = int(options[name])

if callable(getattr(connector, 'ingest', None)):
ingested = connector.ingest(table_name, options)
Expand Down
9 changes: 8 additions & 1 deletion src/webui/backend/webui/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ def post_connector(connector, name):
'errorMessage': f"Missing required configuration options:{missing_titles_str}",
}

# TODO: fix connection options to support secret ints (probs w/ one for loop)
int_option_names = {
o['name'] for o in connector.CONNECTION_OPTIONS if o.get('type') == 'int'
}
for opt_name in int_option_names:
options[opt_name] = int(options[opt_name])

secret_option_names = {
o['name']: o for o in connector.CONNECTION_OPTIONS if o.get('secret')
o['name'] for o in connector.CONNECTION_OPTIONS if o.get('secret')
}
for opt_name in secret_option_names:
if vault.ENABLED and opt_name in options:
Expand Down

0 comments on commit f08cf87

Please sign in to comment.