summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-10-23 15:20:18 -0400
committerGitHub <noreply@github.com>2020-10-23 13:20:18 -0600
commitf5b3ad741679cd42d2c145e574168dafe3ac15c1 (patch)
treed9f43d22c8b50f43fc9b6ac2fe3b31ff40d7fc15 /cloudinit/util.py
parent72d85ff98f4185db10af980776b1ba46fa340920 (diff)
downloadvyos-cloud-init-f5b3ad741679cd42d2c145e574168dafe3ac15c1.tar.gz
vyos-cloud-init-f5b3ad741679cd42d2c145e574168dafe3ac15c1.zip
stages: don't reset permissions of cloud-init.log every boot (#624)
ensure_file needed modification to support doing this, so this commit also includes the following changes: test_util: add tests for util.ensure_file util: add preserve_mode parameter to ensure_file util: add (partial) type annotations to ensure_file LP: #1900837
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index e47f1cf6..83727544 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1804,8 +1804,12 @@ def append_file(path, content):
write_file(path, content, omode="ab", mode=None)
-def ensure_file(path, mode=0o644):
- write_file(path, content='', omode="ab", mode=mode)
+def ensure_file(
+ path, mode: int = 0o644, *, preserve_mode: bool = False
+) -> None:
+ write_file(
+ path, content='', omode="ab", mode=mode, preserve_mode=preserve_mode
+ )
def safe_int(possible_int):