Monokle Validation Plugins need to provide specific metadata for the validation package to use them in the Monokle CLI and Monokle Cloud.
To ensure correct usage/configuration of your plugin the following
properties should be set in a call to definePlugin
id
: a unique (internal) identifier for your pluginname
: a unique camel-case name that will be used as a prefix in configuration files to identify rules in the plugindisplayName
: a user-friendly name for your plugindescription
: a user-friendly description of your plugin
The below example is taken from the Argo Validation plugin in the Community Repository
export default definePlugin({
id: "ARGO",
name: "argo",
displayName: "ArgoCD Validation plugin",
description: "Validation rules related to ArgoCD",
rules: {
appDestination, // defined in the example below
... more rules ...
},
});
Each validator needs to be defined with a call to defineRule
and added to the rules
object shown above.
The following properties are required for defineRule
id
: an internal id for your ruledescription
: a text to show if this rule failshelp
: a text telling how to fix your errors for this rule
Another example from the Argo Validation plugin:
// used in the example above
export const appDestination = defineRule({
id: 2,
description: "Argo Application's destination are mutually exclusive",
help: "Either use 'server' or 'name', but not both.",
validate({ resources }, { report }) {
... validator implementation ...
});
},
});
Plugins need to be contributed to the Community Plugins repository to be directly usable with the Monokle CLI and Monokle Cloud.
Once contributed you can simple use them by adding them to the monokle.validation.yaml
file as follows:
plugins:
<plugin-name>: true
rules:
<pluging-name>/<rule-name>: "err"
The rule-name
is generated from the actual rule property added to the plugin.ts by transforming it into
a lower cased string with dashes between words.
For the above Argo examples the configuration is
# monokle.validation.yaml
plugins:
argo: true
rules:
argo/app-destination: "err"
Read more about the Validator Configuration