Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self, args, **kwargs):
# normalize the file path to allow for relative files to be specified
file_path = os.path.normpath(pjoin(os.getcwd(), args.file))
# load the data (JSON/YAML) from the file
kvps = resource.load_meta_file(file_path)
instances = []
# bail out if file was empty
if not kvps:
return instances
# if the data is not a list (ie. it's a single entry)
# then make it a list so our process loop is generic
if not isinstance(kvps, list):
kvps = [kvps]
for item in kvps:
# parse required KeyValuePair properties
name = item['name']
value = item['value']
def run(self, args, **kwargs):
resources = resource.load_meta_file(args.file)
if not resources:
print('No %s found in %s.' % (self.resource.get_display_name().lower(), args.file))
return None
if not isinstance(resources, list):
resources = [resources]
instances = []
for res in resources:
# pick only the meaningful properties.
data = {
'user': res['user'], # required
'key_hash': res['key_hash'], # required
'metadata': res.get('metadata', {}),
'enabled': res.get('enabled', False)
}
if 'id' in res:
def run(self, args, **kwargs):
resources = resource.load_meta_file(args.file)
if not resources:
print('No %s found in %s.' % (self.resource.get_display_name().lower(), args.file))
return None
if not isinstance(resources, list):
resources = [resources]
instances = []
for res in resources:
# pick only the meaningful properties.
data = {
'user': res['user'], # required
'key_hash': res['key_hash'], # required
'metadata': res.get('metadata', {}),
'enabled': res.get('enabled', False),
}
if 'id' in res: