policy

package
v0.28.1 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 policy provides trust management for project configurations.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInteractive = errors.New("terminal is not interactive")

ErrNotInteractive is returned when a trust prompt is needed but the terminal is not interactive. The caller should skip loading the runtime config.

Functions

This section is empty.

Types

type TrustDecision

type TrustDecision int

TrustDecision represents the user's choice when prompted about an untrusted project.

const (
	// TrustDecisionSkip means the user chose to skip loading the runtime config.
	TrustDecisionSkip TrustDecision = iota
	// TrustDecisionAllow means the user trusts the project and wants to add it to the trust list.
	TrustDecisionAllow
)

type TrustManager

type TrustManager struct {
	// contains filtered or unexported fields
}

TrustManager handles trust decisions for project configurations.

func NewTrustManager

func NewTrustManager(pol *policies.Policy, policyPath string) *TrustManager

NewTrustManager creates a new TrustManager.

func (*TrustManager) LoadTrustedRuntimeConfig

func (m *TrustManager) LoadTrustedRuntimeConfig(
	targetPath string,
	prompter TrustPrompter,
	mode TrustMode,
) (*runtimeconfigs.RuntimeConfig, string, error)

LoadTrustedRuntimeConfig finds and loads a runtime config if it exists and is trusted. Returns nil (not an error) if no runtime config found or if untrusted.

type TrustMode

type TrustMode int

TrustMode controls how runtime configuration trust is handled.

const (
	// TrustModePrompt prompts the user interactively (default).
	TrustModePrompt TrustMode = iota
	// TrustModeAllow trusts runtime configs without prompting (--trust).
	TrustModeAllow
	// TrustModeSkip skips runtime configs without prompting (--no-trust).
	TrustModeSkip
)

type TrustPrompter

type TrustPrompter interface {
	// Prompt prompts the user to decide whether to trust a project configuration.
	// Returns [TrustDecision] and any error (including [ErrNotInteractive]).
	Prompt(projectDir, configPath string) (TrustDecision, error)
}

TrustPrompter handles interactive trust prompts for project configurations.

Jump to

Keyboard shortcuts

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