Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoloading of files #37

Merged
merged 7 commits into from
Dec 15, 2017
Merged

autoloading of files #37

merged 7 commits into from
Dec 15, 2017

Conversation

ygersie
Copy link
Contributor

@ygersie ygersie commented Nov 15, 2017

A basic way of implementing issue #10
If no argument is given we check for the existence of a
levant.nomad jobfile.

If no -var-file is given we check for the existence of a
levant.tf variable file.

This "standardizes" the use of named files and makes pipelines
clean in command usage.

@jrasell
Copy link
Member

jrasell commented Nov 16, 2017

Thanks for all this work @dropje86 I appreciate it. In regards to this one I have a couple of thoughts I would like to discuss:

  • I would prefer that the default loaded variables file is levant.yaml as I use yaml by default so this is a selfish one.
  • When auto-loading the template, I think it would be better to search for *.nomad files in the current working directory and then continue on from there rather than use a card coded levant.nomad job name.

Happy to discuss the points...

@ygersie
Copy link
Contributor Author

ygersie commented Nov 16, 2017

Hi @jrasell

Sure, we could also try both yaml (yml) and tf in that order. Regarding the nomad files, what do you suggest? Run every .nomad file in the working directory and loop through it?

@jrasell
Copy link
Member

jrasell commented Nov 16, 2017

Yeah; looking for either variable file would be perfect.

I would say for the job file that Levant would only run without an explicit template on the CLI if there is only one job file in the current directory; not sure what you think about that?

@ygersie
Copy link
Contributor Author

ygersie commented Nov 16, 2017

So here's a commit which implements that. Please let me know if you agree with putting these into the helper pkg, if not feel free to relocate them or let me know.

@jrasell
Copy link
Member

jrasell commented Nov 22, 2017

@ericwestfall as you requested this feature I would appreciate your feedback on the implementation.

if len(args) == 1 {
templateFile = args[0]
} else if len(args) == 0 {
if templateFile = helper.GetDefaultTmplFile(); templateFile == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we find more than one template file or no template file, it would be ideal if we returned a detailed error message to the user rather than just dumping them back to the usage information and expecting them to guess what went wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

Yorick Gersie added 7 commits December 12, 2017 21:44
  A basic way of implementing issue hashicorp#10
  If no argument is given we check for the existence of a
  levant.nomad jobfile.

  If no -var-file is given we check for the existence of a
  levant.tf variable file.

  This "standardizes" the use of named files and makes pipelines
  clean in command usage.
  * If no TEMPLATE is given as positional arg we scan the working
    directory for *.nomad files. If only 1 match is found we use that to
    proceed.
  * If no -var-file is given we check the working directory for files
    (in this order) named:
    - levant.yaml
    - levant.yml
    - levant.tf
    The first match will be used.
  * improve debug logging for default variable file lookup
  * remove redundant extension logging
@ericwestfall
Copy link

Looks lovely @dropje86!

@jrasell jrasell merged commit 0466ed1 into hashicorp:master Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants