Open nmaludy opened 7 years ago
@lhill and @nmaludy: I looked into this and it appears we aren't strictly following JSONSchema standards which makes this hard to implement with standard jsonschema ref resolvers.
For example, https://spacetelescope.github.io/understanding-json-schema/structuring.html. jsonschema wants people to group inline refs into a "definitions"group. This is super critical. I could actually look for "ref" keyword in "properties" or "patternProperties" and then appropriately resolve the schema but when the parser hits the ref like vcenter here https://github.com/StackStorm-Exchange/stackstorm-vsphere/blob/master/config.schema.yaml#L15, parser won't be able to tell that it was a ref and not an actual object. So basically what I am saying is that the config schema handler today 1. doesn't handle ref 2. the config.schema doesn't really use the JSONSchema strict syntax. I can think of some hacky ways to fix this but ideally I'd want us to think more to see if we can do something better in terms of user simplicity and following jsonschema syntax.
I don't have a good workaround yet. Let me try playing with this more.
I am shocked, shocked to hear that this is complicated.
I suspect that a short-term workaround will be to drop into an editor with the example config
@lakshmi-kannan Yeah, the ref thing I did was a bit of a hack / work-around.
The reason for that is that we don't expose full raw JSON schema functionality for parameters. We basically takes stuff from parameters and put it into "definitions".
See https://github.com/StackStorm/st2/issues/3276 for more details (so we could do some "magic" and put things under special attribute under definitions or similar).
Instead of using JSONSchema references, could we use YAML anchors and references to solve this problem?
There is a PR for the jira pack (StackStorm-Exchange/stackstorm-jira#19) that attempts to implement multiple profiles in the Jira pack config. If I understand this issue correctly, that could also be used here.
See my comment here for a primer.
This is the final config schema.
That PR ran into an issue they could not work around, and I have tried to add a few test cases to our test code, but I couldn't figure out where I should add pack config fixtures and I've been working on unrelated higher priority tasks.
@nmaludy Would you be interested in trying YAML anchors and references to see if that would work for you? Please ping me if you need help.
When running
st2 pack config vsphere
.... if you look at the example config (https://github.com/StackStorm-Exchange/stackstorm-vsphere/blob/master/vsphere.yaml.example) and the schema (https://github.com/StackStorm-Exchange/stackstorm-vsphere/blob/master/config.schema.yaml) it does not seem to be generating a config that matches the example:The yaml file that is generated looks like:
What i want it to look like: