runneroptions

package
v1.0.2-pre.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runneroptions holds options for the function runtime

Index

Constants

View Source
const (
	FuncGenPkgContext = "builtins/gen-pkg-context"
	GHCRImagePrefix   = "ghcr.io/kptdev/krm-functions-catalog"
	PrefixEnvVar      = "KPT_IMAGE_PREFIX"
)

Variables

This section is empty.

Functions

func DefaultImagePrefix

func DefaultImagePrefix() string

DefaultImagePrefix returns the image prefix from the KPT_IMAGE_PREFIX env var, or GHCRImagePrefix if unset.

Types

type CELEnvironment

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

CELEnvironment holds a shared CEL environment for evaluating conditions. The environment is created once and reused; programs are compiled per condition call.

func NewCELEnvironment

func NewCELEnvironment() (*CELEnvironment, error)

NewCELEnvironment creates a new CELEnvironment with the standard KRM variable bindings. Includes cel-go built-in extensions (strings, sets, lists, comprehensions) for evaluating CEL expressions against KRM resources.

func (*CELEnvironment) EvaluateCondition

func (e *CELEnvironment) EvaluateCondition(ctx context.Context, celCond string, resources []*yaml.RNode, checkFrequency uint, costLimit uint64) (bool, error)

EvaluateCondition compiles and evaluates a CEL condition against a list of KRM resources. Returns true if the condition is met, false otherwise. An empty condition always returns true (function executes unconditionally).

type ImagePullPolicy

type ImagePullPolicy string
const (
	AlwaysPull       ImagePullPolicy = "Always"
	IfNotPresentPull ImagePullPolicy = "IfNotPresent"
	NeverPull        ImagePullPolicy = "Never"
)

func (*ImagePullPolicy) AllStrings

func (e *ImagePullPolicy) AllStrings() []string

func (*ImagePullPolicy) HelpAllowedValues

func (e *ImagePullPolicy) HelpAllowedValues() string

HelpAllowedValues builds help text for the allowed values

func (*ImagePullPolicy) Set

func (e *ImagePullPolicy) Set(v string) error

Set implements pflag.Value

func (*ImagePullPolicy) String

func (e *ImagePullPolicy) String() string

String implements pflag.Value and fmt.Stringer

func (*ImagePullPolicy) Type

func (e *ImagePullPolicy) Type() string

Type implements pflag.Value

type LogOptions

type LogOptions struct {
	PkgNameFormat string
	PkgNameSep    string
	PkgNameID     PackageIDType

	// TruncateImageName determines whether the full image name or just the base
	// name and the tag will be logged.
	TruncateImageName bool

	// ResultSeparator is used to join the per-item lines of a function's
	// structured [Results] output. Defaults to "\n" (multi-line) when empty.
	// Embedding applications (e.g. Porch) can set this to "; " to keep the
	// result output on a single line for log-friendliness.
	ResultSeparator string
}

func DefaultLogOptions

func DefaultLogOptions() LogOptions

func (*LogOptions) FillDefaults

func (o *LogOptions) FillDefaults()

func (*LogOptions) IsZero

func (o *LogOptions) IsZero() bool

type PackageIDType

type PackageIDType int8
const (
	// Use directory name to identify the package/subpackage
	DirName PackageIDType = iota
	// Use Kptfile metadata.name to identify the package/subpackage
	KptfileMeta
)

type RunnerOptions

type RunnerOptions struct {
	// ImagePullPolicy controls the image pulling behavior before running the container.
	ImagePullPolicy ImagePullPolicy

	// when set to true, function runner will set the package path annotation
	// on resources that do not have it set. The resources generated by
	// functions do not have this annotation set.
	SetPkgPathAnnotation bool

	DisplayResourceCount bool

	// allowExec determines if function binary executable are allowed
	// to be run during pipeline execution. Running function binaries is a
	// privileged operation, so explicit permission is required.
	AllowExec bool

	// AllowNetwork specifies if container based functions are allowed
	// to access network during pipeline execution. Accessing network is
	// considered a privileged operation (and makes render operation non-hermetic),
	// so explicit permission is desired.
	AllowNetwork bool

	// allowWasm determines if function wasm are allowed to be run during pipeline
	// execution. Running wasm function is an alpha feature, so it needs to be
	// enabled explicitly.
	AllowWasm bool

	// ImagePrefix determines the prefix ResolveToImage will use when resolving a
	// partial image reference to a fully qualified image reference
	ImagePrefix string

	LogOptions LogOptions

	// FullDisplayName is the resolved display name of the package or subpackage.
	// Meant for internal usage, like the render executor.
	FullDisplayName string

	// CELEnvironment is the shared CEL environment used to evaluate function conditions.
	// It is initialized by InitCELEnvironment and reused across all function runners.
	// It may be nil until InitCELEnvironment has been called successfully.
	CELEnvironment *CELEnvironment

	// CelCheckFrequency is the number of CEL evaluation steps before an interruption is checked.
	CelCheckFrequency uint

	// CelCostLimit is the maximum cost of a CEL evaluation.
	CelCostLimit uint64

	ExtraTlsCerts [][]byte
}

func (*RunnerOptions) InitCELEnvironment

func (opts *RunnerOptions) InitCELEnvironment() error

InitCELEnvironment initializes the CEL environment for condition evaluation. This should be called separately after InitDefaults to allow proper error handling. Returns an error if CEL environment creation fails.

func (*RunnerOptions) InitDefaults

func (opts *RunnerOptions) InitDefaults(defaultImagePrefix string)

func (*RunnerOptions) ResolveToImage

func (opts *RunnerOptions) ResolveToImage(image string) string

ResolveToImage converts the KRM function short path to the full image url. If the function is a catalog function, it prepends `prefix`, e.g. "set-namespace:v0.1" --> prefix + "set-namespace:v0.1". A "/" is appended to `prefix` if it is not an empty string and does not end with a "/".

func (*RunnerOptions) ValidatePrefix

func (opts *RunnerOptions) ValidatePrefix() error

ValidatePrefix checks that ImagePrefix is a valid registry path.

type SingleLineFormatter

type SingleLineFormatter struct {
	Title     string   // Label for the output
	Lines     []string // Lines to be joined
	UseQuote  bool     // Whether to quote each line
	Separator string   // Separator between lines (e.g., comma, space)

	Indent     int // How many spaces to indent the whole text
	LineIndent int // How many (extra) spaces to indent each line
}

func (*SingleLineFormatter) String

func (sf *SingleLineFormatter) String() string

Jump to

Keyboard shortcuts

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