From 1f0e17f48c20076d372a66f9bcc0797e2ce7b4f2 Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Thu, 26 Sep 2024 09:30:22 +0200 Subject: [PATCH] Fix titlfile on linux (#753) Signed-off-by: Danil-Grigorev --- tilt/io/Tiltfile | 7 ++++++- tilt/project/Tiltfile | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tilt/io/Tiltfile b/tilt/io/Tiltfile index 52de7405..d0d57c0e 100644 --- a/tilt/io/Tiltfile +++ b/tilt/io/Tiltfile @@ -9,6 +9,11 @@ def dir_create(path): """ local("mkdir -p {}".format(path),echo_off=True,quiet=True) +def prepare_file(path): + """Prepare file for writing""" + + local("echo '' > {}".format(path)) + def file_write(path, contents): """Write contents to a file @@ -17,7 +22,7 @@ def file_write(path, contents): contents: The contents of the file """ - local('echo "$CONTENTS" > {}'.format(path), + local('echo "$CONTENTS" >> {}'.format(path), env={'CONTENTS': str(contents)}, echo_off=True, quiet=True) diff --git a/tilt/project/Tiltfile b/tilt/project/Tiltfile index 72d9d301..c21757d1 100644 --- a/tilt/project/Tiltfile +++ b/tilt/project/Tiltfile @@ -1,7 +1,7 @@ # -*- mode: Python -*- load("../k8s/Tiltfile", "k8s_find_object_name") -load("../io/Tiltfile", "info", "file_write", "dir_create") +load("../io/Tiltfile", "info", "file_write", "dir_create", "prepare_file") def project_enable(name, project, debug): """Enable a project in Tilt @@ -70,7 +70,9 @@ def project_enable(name, project, debug): yaml = kustomize(context + '/' + kustomize_dir) yaml = update_manager(yaml, "manager", debug, env) yaml_path = context + "/.tiltbuild/manifest.yaml" - file_write(yaml_path, yaml) + prepare_file(yaml_path) + for line in str(yaml).splitlines(): + file_write(yaml_path, line) k8s_yaml(yaml) objs = decode_yaml_stream(yaml)