Allow Pegleg to overwrite existing files
Pegleg currently raises an exception when a filepath exists before writing to it in the case of yaml.dump actions. This is not always desired behavior, and with the addition of the flags passed into the files methods for write/append is no longer necessary. Removing these so that overwrite options can take place for example when rotating passphrases or secrets. Change-Id: I2200cc681a797d91a90f6237662fd1ee77954906
This commit is contained in:
parent
d409e35586
commit
36a9a23c9d
@ -239,9 +239,6 @@ def slurp(path):
|
||||
|
||||
|
||||
def dump(data, path, flag='w', **kwargs):
|
||||
if flag == 'w' and os.path.exists(path):
|
||||
raise click.ClickException('%s already exists, aborting' % path)
|
||||
|
||||
os.makedirs(os.path.dirname(os.path.abspath(path)), exist_ok=True)
|
||||
with open(path, flag) as f:
|
||||
|
||||
@ -249,9 +246,6 @@ def dump(data, path, flag='w', **kwargs):
|
||||
|
||||
|
||||
def safe_dump(data, path, flag='w', **kwargs):
|
||||
if flag == 'w' and os.path.exists(path):
|
||||
raise click.ClickException('%s already exists, aborting' % path)
|
||||
|
||||
os.makedirs(os.path.dirname(os.path.abspath(path)), exist_ok=True)
|
||||
with open(path, flag) as f:
|
||||
|
||||
@ -259,9 +253,6 @@ def safe_dump(data, path, flag='w', **kwargs):
|
||||
|
||||
|
||||
def dump_all(data, path, flag='w', **kwargs):
|
||||
if flag == 'w' and os.path.exists(path):
|
||||
raise click.ClickException('%s already exists, aborting' % path)
|
||||
|
||||
os.makedirs(os.path.dirname(os.path.abspath(path)), exist_ok=True)
|
||||
with open(path, flag) as f:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user