It would be nice if we had JSON schemas, similar to this:
https://github.com/lostintangent/packer-schema/blob/master/packer.json
To validate Packer files in IDE's but included in the official source 馃憤
This gives an at glance approach to validation alongside the full packer validate
command.
I'm happy to contribute but wanted to check if there was interest, and one didn't already exist in house.
So I don't think this exists in the source, not in the way you're describing here. I like the idea and can see how this would be nice for validation -- I'd be happy to review code for it but I'd want this schema to be programmatically generated from our mapstructure tags, rather than being a second "source of truth" that we need to remember to maintain by hand.
Totally agree about them being generated, don't want to be hand cranking that stuff.
I'll see what I can do 馃憤
did you make any progress with this, its something I'm interested in too.
@davidcelis Nah I don't know golang in depth enough currently to have a go at this, not in the automated way it should be done anyway.
I'll see what I can do 馃憤
This was me being very optimistic 馃槅
@dkanejs I think you had a mis-mention! /cc @davidwallis3101
These schemas now exist in the form of hcl2specs. Example: https://github.com/hashicorp/packer/blob/master/builder/amazon/ebs/builder.hcl2spec.go
Does this work for your purposes, or must the specs be in json?
It would need to be json for: https://www.jetbrains.com/help/rider/Settings_Languages_JSON_Schema.html
The code that generates the .hcl2spec.go
files (here) could be used to generate the JSON validation schemas. Though I would advise on generating JSON schemas for the _HCL2-JSON_ and not the _old-v1-JSON_ since we are going to deprecate it.
I created some of these manually and put out an internal document to standardize these across Hashicorp. In the meantime mine are available for some of our products and PRs are welcome. Maybe the Packer team can take control. As the push is towards HCL which doesn't have schema support yet it's nice to keep JSON schemas.
https://github.com/jboero/hashicorp-schemas/tree/master/JSON/packer
Most helpful comment
Totally agree about them being generated, don't want to be hand cranking that stuff.
I'll see what I can do 馃憤