diff --git a/src/rpdk/core/project.py b/src/rpdk/core/project.py index 5b5c1b4e..40fe5921 100644 --- a/src/rpdk/core/project.py +++ b/src/rpdk/core/project.py @@ -673,11 +673,13 @@ def _add_overrides_file_to_zip(self, zip_file): LOG.debug("%s found. Writing to package.", OVERRIDES_FILENAME) except FileNotFoundError: LOG.debug("%s not found. Not writing to package.", OVERRIDES_FILENAME) + def _add_resources_content_to_zip(self, zip_file): zip_file.write(self.schema_path, SCHEMA_UPLOAD_FILENAME) if os.path.isdir(self.inputs_path): - for filename in os.listdir(self.inputs_path): + input_files = os.listdir(self.inputs_path) + for filename in list(filter(lambda f: f.endsWith('.json'), input_files)): absolute_path = self.inputs_path / filename zip_file.write(absolute_path, INPUTS_FOLDER + "/" + filename) LOG.debug("%s found. Writing to package.", filename) diff --git a/tests/test_project.py b/tests/test_project.py index d9337ca5..24ad5995 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -91,6 +91,7 @@ PRE_CREATE_INPUTS_FILE = "inputs/inputs_1_pre_create.json" PRE_UPDATE_INPUTS_FILE = "inputs/inputs_1_pre_update.json" INVALID_PRE_DELETE_INPUTS_FILE = "inputs/inputs_1_invalid_pre_delete.json" +README_INPUTS_FILE = "inputs/README.md" PLUGIN_INFORMATION = { "plugin-version": "2.1.3", @@ -1125,7 +1126,7 @@ def test_settings_not_found(project): assert "init" in str(excinfo.value) -def create_input_file(base): +def create_input_files(base): path = base / "inputs" os.mkdir(path, mode=0o777) @@ -1141,6 +1142,11 @@ def create_input_file(base): with path_invalid.open("w", encoding="utf-8") as f: f.write("{}") + # Add a file + path_readme = base / README_INPUTS_FILE + with path_readme.open("w", encoding="utf-8") as f: + f.write("# My README for devs") + def create_hook_input_file(base): path = base / "inputs" @@ -1207,7 +1213,7 @@ def test_submit_dry_run(project, is_type_configuration_available): with project.overrides_path.open("w", encoding="utf-8") as f: f.write(json.dumps(empty_override())) - create_input_file(project.root) + create_input_files(project.root) project.write_settings() @@ -1279,6 +1285,8 @@ def test_submit_dry_run(project, is_type_configuration_available): assert input_invalid == {} input_update = json.loads(zip_file.read(UPDATE_INPUTS_FILE).decode("utf-8")) assert input_update == {} + # ensure we don't add non-json files + assert README_INPUTS_FILE not in zipfile.namelist() assert zip_file.testzip() is None metadata_info = json.loads(zip_file.read(CFN_METADATA_FILENAME).decode("utf-8")) assert "cli-version" in metadata_info @@ -1374,7 +1382,7 @@ def test_submit_dry_run_hooks(project): with project.overrides_path.open("w", encoding="utf-8") as f: f.write(json.dumps(empty_hook_override())) - create_input_file(project.root) + create_input_files(project.root) project.write_settings()