def add_script_as_entrypoint(self): script_path = "{0}/script.sh".format(lambda_instance.temporal_folder) script_content = utils.base64_to_utf8_string( lambda_instance.event['script']) utils.create_file_with_content(script_path, script_content) self.cmd_container_execution += [ "--entrypoint={0} {1}".format(self.script_exec, script_path), self.container_name ]
def create_command(self): self.add_container_volumes() self.add_container_environment_variables() # Container running script if utils.is_value_in_dict(self.lambda_instance.event, 'script'): # Add script in memory as entrypoint script_path = "{0}/script.sh".format(self.lambda_instance.temporal_folder) script_content = utils.base64_to_utf8_string(self.lambda_instance.event['script']) utils.create_file_with_content(script_path, script_content) self.cmd_container_execution += ["--entrypoint={0} {1}".format(self.script_exec, script_path), self.container_name] # Container with args elif utils.is_value_in_dict(self.lambda_instance.event,'cmd_args'): # Add args self.cmd_container_execution += [self.container_name] self.cmd_container_execution += json.loads(self.lambda_instance.event['cmd_args']) # Script to be executed every time (if defined) elif utils.is_variable_in_environment('INIT_SCRIPT_PATH'): # Add init script init_script_path = "{0}/init_script.sh".format(self.lambda_instance.temporal_folder) shutil.copyfile(utils.get_environment_variable("INIT_SCRIPT_PATH"), init_script_path) self.cmd_container_execution += ["--entrypoint={0} {1}".format(self.script_exec, init_script_path), self.container_name] # Only container else: self.cmd_container_execution += [self.container_name]
def create_event_file(self): utils.create_file_with_content( "{0}/event.json".format(lambda_instance.temporal_folder), json.dumps(lambda_instance.event))
def _copy_user_script(self): utils.create_file_with_content( utils.join_paths(self.function_image_folder, 'user_script.sh'), utils.base64_to_utf8_string(self.function_args['script']))