kubeshop/monokle-core

Validation package 'readConfig()' function ignores config 'settings'

Closed this issue · 0 comments

Reading config file like:

plugins:
  yaml-syntax: false
  open-policy-agent: false
  kubernetes-schema: true
  pod-security-standards: true
settings:
  kubernetes-schema:
    schemaVersion: v1.27.1

results in settings being completely ignored.

This seems to be related to a fact that we have incomplete Zod schema there:

export type Config = {
plugins?: PluginMap;
rules?: RuleMap;
settings?: any;
};
export const configSchema: ZodType<Config> = z.object({
name: z.string().optional(),
version: z.string().optional(),
plugins: z.record(z.boolean()).optional(),
rules: z.record(z.boolean().or(z.enum(['warn', 'err']))).optional(),
});
/**
* Parse the configuration as Monokle Config.
*/
export function parseConfig(config: unknown): Config {
return configSchema.parse(config);
}