Skip to content

Commit cd10701

Browse files
improved modify kickoff
1 parent 4dfa9c9 commit cd10701

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

stac_updater/cli.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,25 @@ def update_collection(name, root, long_poll, concurrency):
4545
@click.option('--type', '-t', type=str, default='lambda')
4646
@click.option('--bucket_name', '-n', type=str)
4747
def modify_kickoff(type, bucket_name):
48+
func_name = 'kickoff'
49+
4850
if type == 's3':
49-
kickoff_func = resources.lambda_s3_trigger('kickoff', bucket_name)
51+
kickoff_func = resources.lambda_s3_trigger(func_name, bucket_name)
52+
elif type == 'lambda':
53+
kickoff_func = resources.lambda_invoke(func_name)
5054
else:
51-
kickoff_func = None
52-
53-
if kickoff_func:
54-
# Add kickoff source event to environment
55-
kickoff_func.update({'environment': {
56-
'EVENT_SOURCE': type
57-
}})
58-
with open(sls_config_path, 'r') as f:
59-
sls_config = yaml.unsafe_load(f)
60-
sls_config['functions']['kickoff'].update(kickoff_func)
61-
62-
with open(sls_config_path, 'w') as outf:
63-
yaml.dump(sls_config, outf, indent=1)
55+
raise ValueError("The `type` parameter must be one of ['s3', 'lambda'].")
56+
57+
# Add kickoff source event to environment
58+
kickoff_func.update({'environment': {
59+
'EVENT_SOURCE': type
60+
}})
61+
with open(sls_config_path, 'r') as f:
62+
sls_config = yaml.unsafe_load(f)
63+
sls_config['functions']['kickoff'].update(kickoff_func)
64+
65+
with open(sls_config_path, 'w') as outf:
66+
yaml.dump(sls_config, outf, indent=1)
6467

6568
@stac_updater.command(name='add-notifications')
6669
@click.option('--topic_name', type=str, required=True)

stac_updater/resources.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ def lambda_s3_trigger(func_name, bucket_name):
128128

129129
return func
130130

131+
def lambda_invoke(func_name):
132+
func = {
133+
"handler": f"stac_updater.handler.{func_name}",
134+
}
135+
return func
136+
131137
def update_collection(name, root, filter_rule, long_poll, concurrency):
132138
# Remove all non-alphanumeric characters
133139
pattern = re.compile('[\W_]+')

0 commit comments

Comments
 (0)