check

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package check implements the `mkit check` subcommand: load and lint a policy without running a query.

Index

Constants

This section is empty.

Variables

View Source
var CheckCmd = &cobra.Command{
	Use:   "check <policy.dl>",
	Short: "Load and lint a policy without running a query",
	Long: `Load and lint a policy without running a query.

Checks that the file parses and compiles against the manglekit engine
(including predicate declarations; undeclared or misdeclared predicates
are reported). Exits non-zero on any problem.`,
	Args: cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		path := args[0]

		content, err := os.ReadFile(path)
		if err != nil {
			return fmt.Errorf("failed to read policy file: %w", err)
		}

		e, err := engine.New()
		if err != nil {
			return fmt.Errorf("failed to initialize engine: %w", err)
		}

		if err := e.LoadPolicy(cmd.Context(), string(content)); err != nil {
			return fmt.Errorf("policy %s is invalid: %w", path, err)
		}

		fmt.Fprintf(cmd.OutOrStdout(), "OK: %s parsed and compiled successfully\n", path)
		return nil
	},
}

Functions

func AddCommands

func AddCommands(rootCmd *cobra.Command)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL