runtime

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

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

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

This section is empty.

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

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 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 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