policies

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package policies provides the Policy configuration type for kat.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ValidKinds contains the valid kind values for policy configurations.
	ValidKinds = []string{"Policy"}

	// DefaultValidator validates policy configuration against the JSON schema.
	DefaultValidator = yaml.MustNewValidator("/policies.v1beta1.json", policySchemaJSON)
)

Functions

func GetPath

func GetPath() string

GetPath returns the path to the policy configuration file.

func WriteDefault

func WriteDefault(path string, force bool) error

WriteDefault writes the embedded default policy.yaml to the specified path.

Types

type Policy

type Policy struct {
	Projects         *ProjectsPolicyConfig `json:"projects,omitempty" jsonschema:"title=Projects"`
	v1beta1.TypeMeta `json:",inline"`
}

Policy represents the policy configuration file.

func New

func New() *Policy

New creates a new Policy with default values.

func (*Policy) EnsureDefaults

func (p *Policy) EnsureDefaults()

EnsureDefaults initializes nil fields to their default values.

func (*Policy) IsTrusted

func (p *Policy) IsTrusted(projectPath string) bool

IsTrusted checks if a project path is in the trusted list.

func (Policy) JSONSchemaExtend

func (p Policy) JSONSchemaExtend(jss *jsonschema.Schema)

func (Policy) MarshalYAML

func (p Policy) MarshalYAML() ([]byte, error)

MarshalYAML serializes the policy to YAML.

func (*Policy) TrustProject

func (p *Policy) TrustProject(projectPath, policyPath string) error

TrustProject adds a project to the trust list and persists it to the policy file. This function preserves comments and structure in the policy file.

func (Policy) Write

func (p Policy) Write(path string) error

Write writes the policy to the specified path if it doesn't already exist.

type ProjectsPolicyConfig

type ProjectsPolicyConfig struct {
	// Trust contains a list of trusted projects.
	// Projects in this list will have their configs loaded without prompting.
	// NOTE: You can also use `--trust` or `--no-trust` flags to control this behavior.
	Trust []*TrustedProject `json:"trust,omitempty" jsonschema:"title=Trust"`
}

ProjectsPolicyConfig controls handling of project-specific configurations (.katrc.yaml files).

func (*ProjectsPolicyConfig) EnsureDefaults

func (c *ProjectsPolicyConfig) EnsureDefaults()

EnsureDefaults initializes nil fields to their default values.

type TrustedProject

type TrustedProject struct {
	// Path is the absolute path to a trusted directory.
	Path string `json:"path" jsonschema:"title=Path"`
}

TrustedProject represents a trusted project.

Jump to

Keyboard shortcuts

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