cnabio / cnab-spec

Cloud Native Application Bundle Specification
https://cnab.io
Other
950 stars 100 forks source link

Self contained action schemas #368

Open masaeedu opened 4 years ago

masaeedu commented 4 years ago

It seems like the spec could be made a little bit stupider (in a good way) if the applyTo, definitions, etc. business was replaced with a dictionary of the form:

"actions": {
  "<action name>": {
    "parameters": <json schema>,
    "outputs":  <json schema>
  },
  "<action name>": {
    "parameters": <json schema>,
    "outputs":  <json schema>
  },
  ...
}

Then the parameters can just be presented to the invocation image as a file containing a big opaque schema conformant blob of JSON, and in turn the invocation image can write out a big opaque schema conformant blog of JSON as the output (corresponding to whatever action it ran). If I want to load stuff from the parameters into environment variables or move it around into some weird folder structure where each parameter shows up in a file, I can just have some tools baked into my invocation image that help me do that.

My understanding of the intention behind applyTo, definitions, etc. is that it makes the schema definition DRY, and thus less tedious/error prone to write. However I think it's safe to assume that in many (most?) cases, bundle.json will be machine generated from some other higher-level/more human friendly format. E.g. there's jsonnet and YAML and Dhall and many other such things that can be compiled to a single JSON file, and which deal with imports and reusable variables and so on. Couldn't DRYing out the schema definitions be deferred to those tools?