Skip to content

Commit 163e9d1

Browse files
author
Arik Kfir
committed
Warn instead of failing when "--var-file" provides non-existing files.
1 parent 375b954 commit 163e9d1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/deployster.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from jsonschema import ValidationError
2121

2222
import util
23-
from util import ask, log, err, indent, unindent
23+
from util import ask, log, warn, err, indent, unindent
2424

2525

2626
class UserError(Exception):
@@ -720,10 +720,14 @@ def __init__(self, option_strings, dest, nargs=None, const=None, default=None, t
720720
super().__init__(option_strings, dest, nargs, const, default, type, choices, required, help, metavar)
721721

722722
def __call__(self, parser, namespace, values, option_string=None):
723-
if not hasattr(namespace, self.dest) or not getattr(namespace, self.dest):
724-
setattr(namespace, self.dest, Context())
725-
context: Context = getattr(namespace, self.dest)
726-
context.add_file(values)
723+
if os.path.exists(values):
724+
if not hasattr(namespace, self.dest) or not getattr(namespace, self.dest):
725+
setattr(namespace, self.dest, Context())
726+
context: Context = getattr(namespace, self.dest)
727+
context.add_file(values)
728+
else:
729+
warn(yellow(
730+
f"WARNING: context file '{values}' does not exist (manifest processing might result in errors)."))
727731

728732
# parse arguments
729733
argparser = argparse.ArgumentParser(description="Deployment automation tool.",

0 commit comments

Comments
 (0)