atomicapp icon indicating copy to clipboard operation
atomicapp copied to clipboard

Adds -a option to genanswers to designate where to put answers.conf

Open cdrage opened this issue 9 years ago • 17 comments

Fixues issue: https://github.com/projectatomic/atomicapp/issues/588

Adds the feature to specify the destination of your answers.conf file generation.

cdrage avatar Mar 17 '16 16:03 cdrage

#dotests

cdrage avatar Mar 17 '16 16:03 cdrage

openshift tests = false positive? the timeout issue occured

cdrage avatar Mar 17 '16 18:03 cdrage

Tests pass locally :+1:

cdrage avatar Mar 17 '16 18:03 cdrage

The reason to use -a is symmetry:

genanswers -a demo/answers.conf Nulecule/

atomicapp run -a demo/answers.conf Nulecule/

I understand the arguments for other parameters, but I don't find them persuasive. Anything other than -a is going to require me to look it up.

jberkus avatar Mar 21 '16 15:03 jberkus

I understand the arguments for other parameters, but I don't find them persuasive. Anything other than -a is going to require me to look it up.

This is partly why I decided to have the only behavior to be to put the file in your cwd. If it has one behavior then it is certainly easy to remember. :-P

dustymabe avatar Mar 21 '16 19:03 dustymabe

Except that using the CWD is asymmetrical. That is, "run" requires -a if you want to use an answers.conf, it won't use CWD.

jberkus avatar Mar 21 '16 20:03 jberkus

@dustymabe Should we change this to --destination or stick to -a ? What's your opinion?

cdrage avatar Mar 29 '16 13:03 cdrage

@cdrage here's the instructions I want to be able to give:

  1. generate answers with atomicapp genanswers -a answers.conf Nulecule/
  2. edit answers
  3. run the app atomicapp run -a answers.conf Nulecule/

See the advantage in usability from being symmetric with the use of the -a parameter? The user doesn't have to constantly look up which switch is usable with which command. -a always means answers.conf.

jberkus avatar Mar 29 '16 18:03 jberkus

Relevant to this, the PostgreSQL project used to have different parameters for different commands when it came to databases and the data directory. After years of user bug reports, we refactored and made them consistent; all CLI commands use -D for the data directory and -d for the database, or they don't support those parameters. And the letter 'd' is used for nothing else.

Let's start out by being consistent instead of having to refactor later.

jberkus avatar Mar 29 '16 18:03 jberkus

@cdrage -a is fine.

generate answers with atomicapp genanswers -a answers.conf Nulecule/

@jberkus just so we are clear, my understanding is that command will create an answers.conf file in your current directory. Is that your understanding?

dustymabe avatar Mar 29 '16 21:03 dustymabe

if a directory is not supplied, yes. but if you do this:

atomicapp genanswers -a Nulecule/dev/answers.conf Nulecule/

... then it would create it in Nulecule/dev/ relative to the current directory. Or any other user-supplied directory. Just to keep things simple, if the directory does not exist, it should error.

jberkus avatar Mar 29 '16 21:03 jberkus

#dotests

cdrage avatar Mar 30 '16 13:03 cdrage

@jberkus @dustymabe

Updated this PR to include checking if the directory exists + rebased against master

cdrage avatar Mar 30 '16 13:03 cdrage

Ok a few comments in the code. We also need to decide exactly "what" happens when. Let's create a few cases:

  • User provides path to existing directory
    • aa genanswers -a /path/to/dir
    • => creates /path/to/dir/answers.conf
  • User provides path to a file (not existing) in an existing directory
    • aa genanswers -a /path/to/dir/somefile
    • => creates /path/to/dir/somefile
  • User provides path to a directory that does not exist
    • aa genanswers -a /path/to/no/dir
    • => error - directory does not exist

The hard part about this is number 2. How do we know if the user provided the path to a file that they wanted us to create or they provided us a path to a directory that doesn't exist?

I think we should just make them give us a full file name when providing -a. That way it is simple:

if dirname(file) doesn't exist => error if file exists => error else create file

dustymabe avatar Mar 31 '16 20:03 dustymabe

Will continue on this once #658 is merged so we can use the "are we in a container" util

cdrage avatar Apr 04 '16 17:04 cdrage

Will continue on this once #658 is merged so we can use the "are we in a container" util

No need to wait as we already have the Utils.inContainer() function.

dustymabe avatar Apr 04 '16 19:04 dustymabe

Update: I'm going to pick back up on this soon. ^^

cdrage avatar May 17 '16 19:05 cdrage