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

use a human config format #2

Closed
gregwebs opened this issue Mar 11, 2014 · 7 comments
Closed

use a human config format #2

gregwebs opened this issue Mar 11, 2014 · 7 comments

Comments

@gregwebs
Copy link

JSON is for data interchange. It doesn't support simple necessities such as comments, it was not designed to be a user configuration format.

Possible options are YAML or TOML.
I haven't used TOML, but with YAML I immediately convert it to JSON in my programs.

@michaelsauter
Copy link
Owner

I'm not a huge fan of YAML, and definitely not TOML. Everyone knows how to write JSON, and I don't think it's too cumbersome to write. I also don't see a huge need for comments, Cranefiles should be fairly simple and self-explanatory.
What's great about JSON is that it can be serialised into a string (which can be used instead of a Cranefile).

I might add support for YAML as an alternative though. Not a priority for me, but I'd include it if there's a pull request :)

@gregwebs gregwebs reopened this Mar 12, 2014
@gregwebs
Copy link
Author

What's great about JSON is that it can be serialised into a string (which can be used instead of a Cranefile).

Right, this is why I advocate converting from a human format YAML into a computer format JSON as soon as possible and retaining the ability to send and receive JSON.

Rather than patch this program I am using a converter program yaml2json executable. There are probably lots of them out there for different languages, and if not they are probably fairly easy to write.

@michaelsauter
Copy link
Owner

I definitely want to have JSON as the main format, also because I'm experimenting with this:

crane lift --config='[{"name":"pry", "image":"d11wtq/ruby", "run":{"tty": true, "interactive": true, "cmd": "pry"} }]'

That just cannot be done with YAML. I'm open to allow a crane.yaml though.

@gregwebs
Copy link
Author

I think it could be done in either of these ways: crane lift --config-file=crane.yaml or crane lift < crane.yaml. In fact, I think those are both preferable to putting JSON on the command line because

  • the JSON was originally in a multi-line form unless it was auto-generated
  • if a JSON string contained a single quote it would break the command line

@michaelsauter
Copy link
Owner

Right now, it doesn't make much sense to use --config. I'm thinking about using Crane to read in local configuration, potentially transform it, and send it on the fly to a different host. In that case, a string is the best option.

@gregwebs
Copy link
Author

sure, that makes sense. reading in a configuration can be from a multi-line YAML or JSON file, some settings could be validated, and then the data would be sent as a JSON string.

@gregwebs
Copy link
Author

awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants