-
What are the steps that a mixin author have to do, so the vscode-extension can interpret the mixin schema ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You will want to implement the schema command for your mixin. When the VS Code extension loads, it runs Your mixin is responsible for defining the allowed schema in jsonschema for each action because for some mixins the schema is different per action. Porter will handle parsing through your schema and piecing it all together into a coherent schema for porter.yaml. You just need to worry about what your schema should look like for your portion of the manifest related to the mixin: install:
- helm:
description: Install my wonderful chart
name: myrelease
chart: ./charts/mychart
... The way all the mixins implement that command is by having a packr template schema.json file built into their binary that they print out for the Here is the schema.json for the helm2 mixin: https://github.com/getporter/helm-mixin/blob/main/pkg/helm/schema/schema.json. I recommend copying skeletors new implementation for the schema command and tests. Here's what the test should look like and also the integration test. The skeletor makefile changed to add the integration testing, so you may need to sync back up with it to get that working again. The integration test is useful because otherwise you may see the schema working on your local machine but not in the cross compiled binaries that you publish which is a pain to troubleshoot. This catches that before you release. Really the hard part is getting the json schema right. I recommend for that using https://www.jsonschemavalidator.net/ and https://www.convertjson.com/yaml-to-json.htm to validate that your schema is correct. Also unit tests around that help a lot too! But while you are playing around with it, those web pages are very useful and give you instant feedback and tell you line numbers and where you messed up the json schema. Which ... is where I usually need the most help! 😅 |
Beta Was this translation helpful? Give feedback.
You will want to implement the schema command for your mixin. When the VS Code extension loads, it runs
porter schema
which in turn callsMIXIN schema
against every mixin and composes a single schema file that it provides to VS Code.Your mixin is responsible for defining the allowed schema in jsonschema for each action because for some mixins the schema is different per action. Porter will handle parsing through your schema and piecing it all together into a coherent schema for porter.yaml. You just need to worry about what your schema should look like for your portion of the manifest related to the mixin: