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

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
cdrage committed Mar 30, 2016
1 parent 5e441c4 commit 555c942
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
@@ -52,9 +52,10 @@ def print_app_location(app_path):

def cli_genanswers(args):
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)

@@ -350,6 +351,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='?',
10 changes: 7 additions & 3 deletions atomicapp/nulecule/main.py
Original file line number Diff line number Diff line change
@@ -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.
@@ -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)

0 comments on commit 555c942

Please sign in to comment.