Skip to content
This repository has been archived by the owner on Jan 19, 2018. It is now read-only.

Commit

Permalink
Adds -a option to genanswers to designate where to put answers.conf
Browse files Browse the repository at this point in the history
Fixues issue:
#588

Adds the feature to specify the destination of your answers.conf file
generation.
  • Loading branch information
cdrage committed Mar 17, 2016
1 parent f91da40 commit d7cd453
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion atomicapp/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def print_app_location(app_path):
def cli_genanswers(args):
try:
argdict = args.__dict__
location = argdict['answers']
nm = NuleculeManager(app_spec=argdict['app_spec'],
destination='none')
nm.genanswers(**argdict)
nm.genanswers(location=location, **argdict)
Utils.rm_dir(nm.app_path) # clean up files
sys.exit(0)
except NuleculeException as e:
Expand Down Expand Up @@ -367,6 +368,11 @@ def create_parser(self):
# === "genanswers" SUBPARSER ===
gena_subparser = toplevel_subparsers.add_parser(
"genanswers", parents=[globals_parser])
gena_subparser.add_argument(
"-a",
"--answers",
dest="answers",
help="Path to %s" % ANSWERS_FILE)
gena_subparser.add_argument(
"app_spec",
nargs='?',
Expand Down
10 changes: 7 additions & 3 deletions atomicapp/nulecule/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def unpack(self, update=False,
return Nulecule.load_from_path(
self.app_path, dryrun=dryrun, config=config)

def genanswers(self, dryrun=False, answers_format=None, **kwargs):
def genanswers(self, dryrun=False, answers_format=None, location=None, **kwargs):
"""
Renders artifacts and then generates an answer file. Finally
copies answer file to the current working directory.
Expand All @@ -147,10 +147,14 @@ def genanswers(self, dryrun=False, answers_format=None, **kwargs):
self.answers_format = answers_format or ANSWERS_FILE_SAMPLE_FORMAT

# Check to make sure an answers.conf file doesn't exist already
answers_file = os.path.join(os.getcwd(), ANSWERS_FILE)
if location is None:
answers_file = os.path.join(os.getcwd(), ANSWERS_FILE)
else:
answers_file = os.path.join(location, ANSWERS_FILE)

if os.path.exists(answers_file):
raise NuleculeException(
"Can't generate answers.conf over existing file")
"Can't generate %s over existing file" % answers_file)

# Call unpack to get the app code
self.nulecule = self.unpack(update=False, dryrun=dryrun, config=self.answers)
Expand Down

0 comments on commit d7cd453

Please sign in to comment.