From e443a503d27d85ed72be1cae7aa41bd0ba7f0942 Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Wed, 14 Sep 2022 14:41:38 -0700 Subject: [PATCH] add password strip Signed-off-by: Yee Hing Tong --- flytekit/configuration/file.py | 2 +- tests/flytekit/unit/configuration/test_internal.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flytekit/configuration/file.py b/flytekit/configuration/file.py index 467f660d42..0565dd90a4 100644 --- a/flytekit/configuration/file.py +++ b/flytekit/configuration/file.py @@ -291,4 +291,4 @@ def read_file_if_exists(filename: typing.Optional[str], encoding=None) -> typing filename = pathlib.Path(filename) logger.debug(f"Reading file contents from [{filename}] with current directory [{os.getcwd()}].") - return filename.read_text(encoding=encoding) + return filename.read_text(encoding=encoding).strip() diff --git a/tests/flytekit/unit/configuration/test_internal.py b/tests/flytekit/unit/configuration/test_internal.py index 6ba81f309c..5472c4cca2 100644 --- a/tests/flytekit/unit/configuration/test_internal.py +++ b/tests/flytekit/unit/configuration/test_internal.py @@ -42,6 +42,10 @@ def test_read_file_if_exists(): assert read_file_if_exists(None) is None assert read_file_if_exists("") is None + bad_config_fn = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/bad.config") + first_line = read_file_if_exists(filename=bad_config_fn) + assert not first_line.endswith("\n") + def test_command(): cfg = get_config_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config"))