runtime

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 34 Imported by: 31

Documentation

Index

Constants

View Source
const (
	// VelaPrefix default prefix for internal package names
	VelaPrefix = "vela/"
)

Variables

View Source
var DefaultClient = singleton.NewSingleton(func() *http.Client {
	return &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: DefaultClientInsecureSkipVerify},
		},
	}
})

DefaultClient client for dealing requests

View Source
var DefaultClientInsecureSkipVerify = true

DefaultClientInsecureSkipVerify set if the default external provider client use insecure-skip-verify

Functions

func ContextFromHeaders added in v1.10.0

func ContextFromHeaders(r *http.Request) context.Context

ContextFromHeaders extracts the span context and baggage from an HTTP request and returns the reconstructed ctx.

func StartSpan added in v1.10.0

func StartSpan(ctx context.Context, name string) (context.Context, trace.Span)

StartSpan creates a new OpenTelemetry span and returns the updated context and span.

func StartSpanWithBaggage added in v1.10.0

func StartSpanWithBaggage(ctx context.Context, name string, hCtx json.Marshaler) (context.Context, trace.Span, error)

StartSpanWithBaggage creates a new OpenTelemetry span and attaches encoded JSON context as baggage.

func WithBaggage added in v1.10.0

func WithBaggage(ctx context.Context, b map[string]string) (context.Context, error)

WithBaggage appends additional baggage entries to the context.

Types

type CUETemplater

type CUETemplater interface {
	GetName() string
	GetPath() string
	GetTemplates() []string
	GetImports() []*build.Instance
}

CUETemplater the interface for retrieving cue templates and imports

type ExternalProviderFn

type ExternalProviderFn struct {
	v1alpha1.Provider
	Fn string
}

ExternalProviderFn external provider that implements ProviderFn interface

func (*ExternalProviderFn) Call

func (in *ExternalProviderFn) Call(ctx context.Context, value cue.Value) (cue.Value, error)

Call dial external endpoints by passing the json data of the input parameter, then fill back returned values

func (*ExternalProviderFn) InjectHeaders added in v1.10.0

func (in *ExternalProviderFn) InjectHeaders(ctx context.Context, r *http.Request)

InjectHeaders Injects headers from the current span into the http request headers

type GenericProviderFn

type GenericProviderFn[T any, U any] func(context.Context, *T) (*U, error)

GenericProviderFn generic function that implements ProviderFn interface

func (GenericProviderFn[T, U]) Call

func (fn GenericProviderFn[T, U]) Call(ctx context.Context, value cue.Value) (cue.Value, error)

Call marshal value into json and decode into underlying function input parameters, then fill back the returned output value

type NativeProviderFn

type NativeProviderFn func(context.Context, cue.Value) (cue.Value, error)

NativeProviderFn native function that implements ProviderFn interface

func (NativeProviderFn) Call

func (fn NativeProviderFn) Call(ctx context.Context, value cue.Value) (cue.Value, error)

Call .

type Package

type Package interface {
	Provider
	CUETemplater
}

Package composed by Provider & CUETemplater, the atomic unit for engine to use

func NewExternalPackage

func NewExternalPackage(src *v1alpha1.Package) (Package, error)

NewExternalPackage create Package based on given CRD object

func NewInternalPackage

func NewInternalPackage(name string, template string, fns map[string]ProviderFn) (Package, error)

NewInternalPackage create package based on given functions

type PackageManager

type PackageManager struct {
	Internals *maps.SyncMap[string, Package]
	Externals *maps.SyncMap[string, Package]

	ResyncPeriod time.Duration
	StopCh       chan struct{}
}

PackageManager manages cue packages

func NewPackageManager

func NewPackageManager(opts ...PackageManagerOption) *PackageManager

NewPackageManager create PackageManager with given options

func (*PackageManager) GetImports

func (in *PackageManager) GetImports() []*build.Instance

GetImports return all build.Instances built by given packages

func (*PackageManager) GetPackages

func (in *PackageManager) GetPackages() []Package

GetPackages return all internal and external packages

func (*PackageManager) GetProviders

func (in *PackageManager) GetProviders() map[string]Provider

GetProviders return all providers provisioned by given packages

func (*PackageManager) ListenExternalPackages

func (in *PackageManager) ListenExternalPackages(stopCh <-chan struct{})

ListenExternalPackages start informer to listen external package changes

func (*PackageManager) LoadExternalPackages

func (in *PackageManager) LoadExternalPackages(ctx context.Context) error

LoadExternalPackages load all external packages

func (*PackageManager) LoadInternalPackages

func (in *PackageManager) LoadInternalPackages(pkgs ...Package)

LoadInternalPackages load given internal packages

type PackageManagerOption

type PackageManagerOption interface {
	ApplyTo(*PackageManager)
}

PackageManagerOption option for configuring PackageManager

type PropagatedCtx added in v1.10.0

type PropagatedCtx struct {
	context.Context
	// contains filtered or unexported fields
}

PropagatedCtx .

func GetPropagatedContext added in v1.10.0

func GetPropagatedContext(ctx context.Context) (*PropagatedCtx, bool)

GetPropagatedContext retrieves the PropagatedCtx from the given context if present.

func (*PropagatedCtx) GetCueContext added in v1.10.0

func (p *PropagatedCtx) GetCueContext() (*cue.Value, error)

GetCueContext returns the embedded JSON context as a CUE value.

func (*PropagatedCtx) RawJSON added in v1.10.0

func (p *PropagatedCtx) RawJSON() json.RawMessage

RawJSON returns the embedded JSON context as a json.RawMessage.

func (*PropagatedCtx) UnmarshalContext added in v1.10.0

func (p *PropagatedCtx) UnmarshalContext(out interface{}) error

UnmarshalContext unmarshals the embedded JSON context into the provided struct.

type Provider

type Provider interface {
	GetName() string
	GetProviderFn(do string) ProviderFn
}

Provider the interface to get provider function

type ProviderFn

type ProviderFn interface {
	Call(context.Context, cue.Value) (cue.Value, error)
}

ProviderFn the function interface to process cue values

type TraceHeaderPropagator added in v1.10.0

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

TraceHeaderPropagator .

func (TraceHeaderPropagator) Extract added in v1.10.0

Extract reconstructs the span context and baggage from the provided HTTP headers.

func (TraceHeaderPropagator) Fields added in v1.10.0

func (cp TraceHeaderPropagator) Fields() []string

Fields returns the list of HTTP headers used for trace context propagation.

func (TraceHeaderPropagator) Inject added in v1.10.0

Inject serializes the span baggage and trace context into the provided HTTP headers.

type WithInternalPackage

type WithInternalPackage struct {
	Package
}

WithInternalPackage add internal package

func (WithInternalPackage) ApplyTo

func (in WithInternalPackage) ApplyTo(m *PackageManager)

ApplyTo .

type WithResyncPeriod

type WithResyncPeriod time.Duration

WithResyncPeriod set resync period for external package informer

func (WithResyncPeriod) ApplyTo

func (in WithResyncPeriod) ApplyTo(m *PackageManager)

ApplyTo .

Jump to

Keyboard shortcuts

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