python

package
v0.6.71 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Overview

Package python executes the user-provided Python used by Helm value templating.

Scripts run in a fresh Gomonty REPL for every job. The sandbox does not expose OS, filesystem, network, or environment access. Host callbacks are limited to the read-only k8s_object_meta lookup against the agent cache and the pure yaml_encode, yaml_decode, and merge helpers.

Index

Constants

View Source
const (
	// ExecutionTimeout bounds queue admission and execution for one job.
	ExecutionTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func SetDefaultPool

func SetDefaultPool(pool *Pool)

SetDefaultPool installs the process-wide pool used by Helm rendering. The caller owns the pool and must close it during application shutdown.

func SetObjectMetaLookup added in v0.6.67

func SetObjectMetaLookup(fn ObjectMetaLookup)

SetObjectMetaLookup installs the process-wide cache lookup used by k8s_object_meta. Pass nil to clear it.

Types

type Config

type Config struct {
	MaxConcurrentReconciles int
	WorkerCount             int
	QueueSize               int
	ExecutionTimeout        time.Duration
}

Config controls a Pool. WorkerCount and QueueSize are intended primarily for focused tests. Production callers should set MaxConcurrentReconciles so the fixed pool sizing policy is applied at startup.

type ObjectMetaLookup added in v0.6.67

type ObjectMetaLookup func(group, version, kind, namespace, name string) (map[string]any, error)

ObjectMetaLookup returns cached Kubernetes object metadata for Helm Python scripts. A nil map means the object is not in the cache.

type Pool

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

Pool owns a fixed set of workers and a bounded queue. It is safe for concurrent use. Close waits for workers to stop and is idempotent.

func DefaultPool

func DefaultPool() *Pool

DefaultPool returns the pool installed by the application startup path.

func NewPool

func NewPool(maxConcurrentReconciles int) (*Pool, error)

NewPool creates and health-checks a fixed-size worker pool. The health check eagerly loads Gomonty's native runtime, making startup failures visible before the first service render.

func NewPoolWithConfig

func NewPoolWithConfig(config Config) (*Pool, error)

NewPoolWithConfig is the configurable constructor used by tests and by callers that need to provide an explicit pool size.

func (*Pool) Close

func (p *Pool) Close() error

Close stops accepting work, cancels executing jobs, and waits for all workers. Jobs that have not started are discarded with the pool.

func (*Pool) Run

func (p *Pool) Run(ctx context.Context, script string, bindings map[string]any) (Result, error)

Run submits one script to the bounded pool. The timeout starts before queue admission, so a queued job cannot extend the caller's end-to-end deadline.

type Result

type Result struct {
	Values      map[string]any
	ValuesFiles []string
	// Warnings are non-fatal messages reported back to the service as warnings.
	Warnings []string
}

Result is the strict shape returned by a Python templating script.

Jump to

Keyboard shortcuts

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