Documentation
¶
Index ¶
- Constants
- Variables
- func FilesystemFromRepo(uri string) (filesystem.Filesystem, error)
- func Interpolate(ee []Env) (map[string]string, error)
- func LastSpecVersion() string
- func RepositoriesPath() string
- func ValidateBuildEnvs(envs []Env) (errors []string)
- func ValidateEnvs(envs []Env) (errors []string)
- func ValidateLabels(labels []Label) (errors []string)
- type BuildConfig
- type BuildSpec
- type Builder
- type Client
- func (c *Client) Apply(ctx context.Context, f Function) (string, Function, error)
- func (c *Client) Build(ctx context.Context, f Function) (Function, error)
- func (c *Client) ConfigurePAC(ctx context.Context, f Function, metadata any) error
- func (c *Client) Deploy(ctx context.Context, f Function, opts ...DeployOption) (Function, error)
- func (c *Client) Describe(ctx context.Context, name string, f Function) (d Instance, err error)
- func (c *Client) Init(cfg Function) (Function, error)
- func (c *Client) Instances() *InstanceRefs
- func (c *Client) Invoke(ctx context.Context, root string, target string, m InvokeMessage) (metadata map[string][]string, body string, err error)
- func (c *Client) List(ctx context.Context) ([]ListItem, error)
- func (c *Client) New(ctx context.Context, cfg Function) (string, Function, error)
- func (c *Client) Push(ctx context.Context, f Function) (Function, error)
- func (c *Client) Registry() string
- func (c *Client) Remove(ctx context.Context, cfg Function, deleteAll bool) error
- func (c *Client) RemovePAC(ctx context.Context, f Function, metadata any) error
- func (c *Client) Repositories() *Repositories
- func (c *Client) RepositoriesPath() (path string)
- func (c *Client) Route(ctx context.Context, f Function) (string, Function, error)
- func (c *Client) Run(ctx context.Context, f Function) (job *Job, err error)
- func (c *Client) RunPipeline(ctx context.Context, f Function) (Function, error)
- func (c *Client) Runtimes() ([]string, error)
- func (c *Client) Templates() *Templates
- func (c *Client) Update(ctx context.Context, f Function) (string, Function, error)
- type DNSProvider
- type DeployOption
- type DeployParams
- type DeploySpec
- type Deployer
- type DeploymentResult
- type Describer
- type Env
- type Function
- func (f Function) Built() bool
- func (f Function) ImageName() (image string, err error)
- func (f Function) ImageWithDigest() string
- func (f Function) Initialized() bool
- func (f Function) LabelsMap() (map[string]string, error)
- func (f Function) Migrate() (migrated Function, err error)
- func (f Function) Migrated() bool
- func (f Function) Validate() error
- func (f Function) Write() (err error)
- type Git
- type HealthEndpoints
- type Instance
- type InstanceRefs
- type InvokeMessage
- type Job
- type Label
- type ListItem
- type Lister
- type NoopProgressListener
- type Option
- func WithBuilder(d Builder) Option
- func WithDNSProvider(provider DNSProvider) Option
- func WithDeployer(d Deployer) Option
- func WithDescriber(describer Describer) Option
- func WithLister(l Lister) Option
- func WithPipelinesProvider(pp PipelinesProvider) Option
- func WithProgressListener(p ProgressListener) Option
- func WithPusher(d Pusher) Option
- func WithRegistry(registry string) Option
- func WithRemover(r Remover) Option
- func WithRepositoriesPath(path string) Option
- func WithRepository(uri string) Option
- func WithRunner(r Runner) Option
- func WithTransport(t http.RoundTripper) Option
- func WithVerbose(v bool) Option
- type Options
- type PipelinesProvider
- type ProgressListener
- type Pusher
- type Remover
- type Repositories
- func (r *Repositories) Add(name, uri string) (string, error)
- func (r *Repositories) All() (repos []Repository, err error)
- func (r *Repositories) Get(name string) (repo Repository, err error)
- func (r *Repositories) List() ([]string, error)
- func (r *Repositories) Path() string
- func (r *Repositories) Remove(name string) error
- func (r *Repositories) Rename(from, to string) error
- type Repository
- func (r *Repository) Runtime(name string) (runtime Runtime, err error)
- func (r *Repository) Template(runtimeName, name string) (t Template, err error)
- func (r *Repository) Templates(runtimeName string) ([]Template, error)
- func (r *Repository) URL() string
- func (r *Repository) Write(dest string) (err error)
- type ResourcesLimitsOptions
- type ResourcesOptions
- type ResourcesRequestsOptions
- type RunSpec
- type Runner
- type Runtime
- type ScaleOptions
- type Status
- type Subscription
- type Template
- type Templates
- type Volume
Constants ¶
const ( // DefaultRegistry through which containers of functions will be shuttled. DefaultRegistry = "docker.io" // DefaultTemplate is the default function signature / environmental context // of the resultant function. All runtimes are expected to have at least // one implementation of each supported function signature. Currently that // includes an HTTP Handler ("http") and Cloud Events handler ("events") DefaultTemplate = "http" )
const ( // FunctionFile is the file used for the serialized form of a function. FunctionFile = "func.yaml" // RunDataDir holds transient runtime metadata // By default it is excluded from source control. RunDataDir = ".func" // DefaultPersistentVolumeClaimSize represents default size of PVC created for a Pipeline DefaultPersistentVolumeClaimSize string = "256Mi" )
const ( EnvironmentLocal = "local" EnvironmentRemote = "remote" )
const ( DefaultInvokeSource = "/boson/fn" DefaultInvokeType = "boson.fn" DefaultInvokeContentType = "application/json" DefaultInvokeData = `{"message":"Hello World"}` DefaultInvokeFormat = "http" )
const ( // DefaultReadinessEndpoint for final deployed function instances DefaultReadinessEndpoint = "/health/readiness" // DefaultLivenessEndpoint for final deployed function instances DefaultLivenessEndpoint = "/health/liveness" // DefaultTemplatesPath is the root of the defined repository DefaultTemplatesPath = "." // DefaultInvocationFormat is a named invocation hint for the convenience // helper .Invoke. It is usually set at the template level. The default // ('http') is a plain HTTP POST. DefaultInvocationFormat = "http" )
const ( // DefaultRepositoryName is the name by which the currently default repo can // be referred. This name is assumed when no template prefix is provided // when determining a template canonical (full) name. // Unless a single-repo override is defined, this is usually referring to the // builtin (embedded) repository. DefaultRepositoryName = "default" )
Variables ¶
var ( ErrNotInitialized = errors.New("function is not initialized") ErrNotRunning = errors.New("function not running") ErrRootRequired = errors.New("function root path is required") ErrEnvironmentNotFound = errors.New("environment not found") ErrMismatchedName = errors.New("name passed does not match name of the function at root") )
var ( ErrRepositoryNotFound = errors.New("repository not found") ErrRepositoriesNotDefined = errors.New("custom template repositories location not specified") ErrTemplatesNotFound = errors.New("templates path (runtimes) not found") ErrRuntimeNotFound = errors.New("language runtime not found") ErrRuntimeRequired = errors.New("language runtime required") ErrTemplateNotFound = errors.New("template not found") ErrTemplateMissingRepository = errors.New("template name missing repository prefix") )
var EmbeddedTemplatesFS filesystem.Filesystem = newEmbeddedTemplatesFS()
var ErrNameRequired = errors.New("name required")
ErrNameRequired indicates the operation requires a name to complete.
var ErrNotBuilt = errors.New("not built")
ErrNotBuilt indicates the function has not yet been built.
var ErrRegistryRequired = errors.New("registry required to build function, please set with `--registry` or the FUNC_REGISTRY environment variable")
ErrRegistryRequired indicates the operation requires a registry to complete.
Functions ¶
func FilesystemFromRepo ¶
func FilesystemFromRepo(uri string) (filesystem.Filesystem, error)
FilesystemFromRepo attempts to fetch a filesystem from a git repository indicated by the given URI. Returns nil if there is not a repo at the URI.
func Interpolate ¶
Interpolate Env slice Values with no special format are preserved as simple values. Values which do include the interpolation format (begin with {{) but are not keyed as "env" are also preserved as is. Values properly formatted as {{ env:NAME }} are interpolated (substituted) with the value of the local environment variable "NAME", and an error is returned if that environment variable does not exist.
func LastSpecVersion ¶
func LastSpecVersion() string
LastSpecVersion returns the string value for the most recent migration
func RepositoriesPath ¶
func RepositoriesPath() string
RepositoriesPath is a convenience method for accessing the default path to repositories that will be used by new instances of a Client unless options such as WithRepositoriesPath are used to override. The path will be created if it does not already exist.
func ValidateBuildEnvs ¶
ValidateBuildEnvs checks that input BuildEnvs are correct and contain all necessary fields. Returns array of error messages, empty if no errors are found
Allowed settings:
- name: EXAMPLE1 # ENV directly from a value value: value1
- name: EXAMPLE2 # ENV from the local ENV var value: {{ env:MY_ENV }}
func ValidateEnvs ¶
ValidateEnvs checks that input Envs are correct and contain all necessary fields. Returns array of error messages, empty if no errors are found
Allowed settings:
- name: EXAMPLE1 # ENV directly from a value value: value1
- name: EXAMPLE2 # ENV from the local ENV var value: {{ env:MY_ENV }}
- name: EXAMPLE3 value: {{ secret:secretName:key }} # ENV from a key in secret
- value: {{ secret:secretName }} # all key-pair values from secret are set as ENV
- name: EXAMPLE4 value: {{ configMap:configMapName:key }} # ENV from a key in configMap
- value: {{ configMap:configMapName }} # all key-pair values from configMap are set as ENV
func ValidateLabels ¶
ValidateLabels checks that input labels are correct and contain all necessary fields. Returns array of error messages, empty if no errors are found
Allowed settings:
- key: EXAMPLE1 # label directly from a value value: value1
- key: EXAMPLE2 # label from the local ENV var value: {{ env:MY_ENV }}
Types ¶
type BuildConfig ¶
type BuildConfig struct { Buildpacks []string `yaml:"buildpacks,omitempty"` BuilderImages map[string]string `yaml:"builderImages,omitempty"` }
BuildConfig defines builders and buildpacks
type BuildSpec ¶
type BuildSpec struct { // Git stores information about an optionally associated git repository. Git Git `yaml:"git,omitempty"` // BuilderImages define optional explicit builder images to use by // builder implementations in leau of the in-code defaults. They key // is the builder's short name. For example: // builderImages: // pack: example.com/user/my-pack-node-builder // s2i: example.com/user/my-s2i-node-builder BuilderImages map[string]string `yaml:"builderImages,omitempty"` // Optional list of buildpacks to use when building the function Buildpacks []string `yaml:"buildpacks,omitempty"` // Builder is the name of the subsystem that will complete the underlying // build (pack, s2i, etc) Builder string `yaml:"builder,omitempty" jsonschema:"enum=pack,enum=s2i"` // Build Env variables to be set BuildEnvs []Env `yaml:"buildEnvs,omitempty"` // PVCSize specifies the size of persistent volume claim used to store function // when using deployment and remote build process (only relevant when Remote is true). PVCSize string `yaml:"pvcSize,omitempty"` }
BuildSpec
type Builder ¶
type Builder interface { // Build a function project with source located at path. Build(context.Context, Function) error }
Builder of function source to runnable image.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for managing function instances.
func (*Client) Apply ¶
Apply (aka upsert)
The general-purpose high-level method to initiate a synchronization of a function's source code and it's deployed instance(s).
Invokes all lower-level methods, including initialization, as necessary to create a running function whose source code and metadata match that provided by the passed function instance, returning the final route and any errors.
func (*Client) Build ¶
Build the function at path. Errors if the function is either unloadable or does not contain a populated Image.
func (*Client) ConfigurePAC ¶
ConfigurePAC generates Pipeline resources on the local filesystem, on the cluster and also on the remote git provider (ie. GitHub, GitLab or BitBucket repo)
func (*Client) Describe ¶
Describe a function. Name takes precedence. If no name is provided, the function defined at root is used.
func (*Client) Init ¶
Initialize a new function with the given function struct defaults. Does not build/push/deploy. Local FS changes only. For higher-level control see New or Apply.
<path> will default to the absolute path of the current working directory. <name> will default to the current working directory. When <name> is provided but <path> is not, a directory <name> is created in the current working directory and used for <path>.
func (*Client) Invoke ¶
func (c *Client) Invoke(ctx context.Context, root string, target string, m InvokeMessage) (metadata map[string][]string, body string, err error)
Invoke is a convenience method for triggering the execution of a function for testing and development. Returned is a map of metadata and a stringified version of the content. The target argument is optional, naming the running instance of the function which should be invoked. This can be the literal names "local" or "remote", or can be a URL to an arbitrary endpoint. If not provided, a running local instance is preferred, with the remote function triggered if there is no locally running instance. Example:
myClient.Invoke(myContext, myFunction, "local", NewInvokeMessage())
The message sent to the function is defined by the invoke message. See NewInvokeMessage for its defaults. Functions are invoked in a manner consistent with the settings defined in their metadata. For example HTTP vs CloudEvent
func (*Client) New ¶
New function.
Creates a new running function from the path indicated by the config Function. Used by Apply when the path is not yet an initialized function. Errors if the path is alrady an initialized function.
Use Init, Build, Push, Deploy etc. independently for lower level control. Returns the primary route to the function or error.
func (*Client) Registry ¶
Repository accessor returns the default registry for use when building Functions which do not specify Registry or Image name explicitly.
func (*Client) Remove ¶
Remove a function. Name takes precedence. If no name is provided, the function defined at root is used if it exists.
func (*Client) RemovePAC ¶
RemovePAC deletes generated Pipeline as Code resources on the local filesystem and on the cluster
func (*Client) RepositoriesPath ¶
RepositoriesPath accesses the currently effective repositories path, which can be set using the WithRepositoriesPath option.
func (*Client) Route ¶
Route returns the current primary route to the function at root.
Note that local instances of the Function created by the .Run method are not considered here. This method is intended to specifically apply to the logical group of function instances actually available as network sevices; this excludes local testing instances.
For access to these local test function instances routes, use the instances manager directly ( see .Instances().Get() ).
func (*Client) Run ¶
Run the function whose code resides at root. On start, the chosen port is sent to the provided started channel
func (*Client) RunPipeline ¶
RunPipeline runs a Pipeline to build and deploy the function. Returned function contains applicable registry and deployed image name.
func (*Client) Runtimes ¶
Runtimes available in totality. Not all repository/template combinations necessarily exist, and further validation is performed when a template+runtime is chosen. from a given repository. This is the global list of all available. Returned list is unique and sorted.
type DNSProvider ¶
type DNSProvider interface { // Provide the given name by routing requests to address. Provide(Function) error }
DNSProvider exposes DNS services necessary for serving the function.
type DeployOption ¶
type DeployOption func(f *DeployParams)
func WithDeploySkipBuildCheck ¶
func WithDeploySkipBuildCheck(skipBuiltCheck bool) DeployOption
type DeployParams ¶
type DeployParams struct {
// contains filtered or unexported fields
}
type DeploySpec ¶
type DeploySpec struct { // Namespace into which the function is deployed on supported platforms. Namespace string `yaml:"namespace,omitempty"` // Remote indicates the deployment (and possibly build) process are to // be triggered in a remote environment rather than run locally. Remote bool `yaml:"remote,omitempty"` // Map containing user-supplied annotations // Example: { "division": "finance" } Annotations map[string]string `yaml:"annotations,omitempty"` // Options to be set on deployed function (scaling, etc.) Options Options `yaml:"options,omitempty"` // Map of user-supplied labels Labels []Label `yaml:"labels,omitempty"` // Health endpoints specified by the language pack HealthEndpoints HealthEndpoints `yaml:"healthEndpoints,omitempty"` // ServiceAccountName is the name of the service account used for the // function pod. The service account must exist in the namespace to // succeed. // More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ ServiceAccountName string `yaml:"serviceAccountName,omitempty"` }
DeploySpec
type Deployer ¶
type Deployer interface { // Deploy a function of given name, using given backing image. Deploy(context.Context, Function) (DeploymentResult, error) }
Deployer of function source to running status.
type DeploymentResult ¶
type Describer ¶
type Describer interface { // Describe the named function in the remote environment. Describe(ctx context.Context, name string) (Instance, error) }
Describer of function instances
type Env ¶
type Env struct { Name *string `yaml:"name,omitempty" jsonschema:"pattern=^[-._a-zA-Z][-._a-zA-Z0-9]*$"` Value *string `yaml:"value,omitempty"` }
func (Env) KeyValuePair ¶
KeyValuePair returns a string representation of the Env field in form NAME=VALUE if NAME is not defined for an Env, empty string is returned
type Function ¶
type Function struct { // SpecVersion at which this function is known to be compatible. // More specifically, it is the highest migration which has been applied. // For details see the .Migrated() and .Migrate() methods. SpecVersion string `yaml:"specVersion"` // semver format // Root on disk at which to find/create source and config files. Root string `yaml:"-"` // Name of the function. Name string `yaml:"name,omitempty" jsonschema:"pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"` // Runtime is the language plus context. nodejs|go|quarkus|rust etc. Runtime string `yaml:"runtime,omitempty"` // Template for the function. Template string `yaml:"-"` // Registry at which to store interstitial containers, in the form // [registry]/[user]. Registry string `yaml:"registry"` // Optional full OCI image tag in form: // [registry]/[namespace]/[name]:[tag] // example: // quay.io/alice/my.function.name // Registry is optional and is defaulted to DefaultRegistry // example: // alice/my.function.name // If Image is provided, it overrides the default of concatenating // "Registry+Name:latest" to derive the Image. Image string `yaml:"image"` // SHA256 hash of the latest image that has been built ImageDigest string `yaml:"imageDigest,omitempty"` // Created time is the moment that creation was successfully completed // according to the client which is in charge of what constitutes being // fully "Created" (aka initialized) Created time.Time `yaml:"created"` // Invoke defines hints for use when invoking this function. // See Client.Invoke for usage. Invoke string `yaml:"invoke,omitempty"` //BuildSpec define the build properties for a function Build BuildSpec `yaml:"build,omitempty"` //RunSpec define the runtime properties for a function Run RunSpec `yaml:"run,omitempty"` //DeploySpec define the deployment properties for a function Deploy DeploySpec `yaml:"deploy,omitempty"` // current (last) build stamp for the function if it can be found. BuildStamp string `yaml:"-"` // flags that buildstamp needs to be saved to disk NeedsWriteBuildStamp bool `yaml:"-"` }
Function
func NewFunction ¶
NewFunction from a given path. Invalid paths, or no function at path are errors. Syntactic errors are returned immediately (yaml unmarshal errors). Functions which are syntactically valid are also then logically validated. Functions from earlier versions are brought up to current using migrations. Migrations are run prior to validators such that validation can omit concerning itself with backwards compatibility. Migrators must therefore selectively consider the minimal validation necessary to enable migration.
func NewFunctionWith ¶
NewFunctionWith defaults as provided.
func (Function) Built ¶
Built returns true if the given path contains a function which has been built without any filesystem modifications since (is not stale).
func (Function) ImageName ¶
ImageName returns a full image name (OCI container tag) for the Function based off of the Function's `Registry` member plus `Name`. Used to calculate the final value for .Image when none is provided explicitly.
form: [registry]/[user]/[function]:latest example: quay.io/alice/my.function.name:latest
Also nested namespaces should be supported: form: [registry]/[parent]/[user]/[function]:latest example: quay.io/project/alice/my.function.name:latest
Registry values which only contain a single token are presumed to indicate the namespace at the default registry.
func (Function) ImageWithDigest ¶
ImageWithDigest returns the full reference to the image including SHA256 Digest. If Digest is empty, image:tag is returned. TODO: Populate this only on a successful deploy, as this results on a dirty git tree on every build.
func (Function) Initialized ¶
Initialized returns if the function has been initialized. Any errors are considered failure (invalid or inaccessible root, config file, etc).
func (Function) LabelsMap ¶
LabelsMap combines default labels with the labels slice provided. It will the resulting slice with ValidateLabels and return a key/value map.
- key: EXAMPLE1 # Label directly from a value value: value1
- key: EXAMPLE2 # Label from the local ENV var value: {{ env:MY_ENV }}
func (Function) Migrate ¶
Migrate applies any necessary migrations, returning a new migrated version of the function. It is the caller's responsibility to .Write() the function to persist to disk.
func (Function) Migrated ¶
Migrated returns whether the function has been migrated to the highest level the currently executing system is aware of (or beyond). returns true.
type HealthEndpoints ¶
type HealthEndpoints struct { Liveness string `yaml:"liveness,omitempty"` Readiness string `yaml:"readiness,omitempty"` }
HealthEndpoints specify the liveness and readiness endpoints for a Runtime
type Instance ¶
type Instance struct { // Route is the primary route of a function instance. Route string // Routes is the primary route plus any other route at which the function // can be contacted. Routes []string `json:"routes" yaml:"routes"` Name string `json:"name" yaml:"name"` Image string `json:"image" yaml:"image"` Namespace string `json:"namespace" yaml:"namespace"` Subscriptions []Subscription `json:"subscriptions" yaml:"subscriptions"` }
Instance data about the runtime state of a function in a given environment.
A function instance is a logical running function space, which share a unique route (or set of routes). Due to autoscaling and load balancing, there is a one to many relationship between a given route and processes. By default the system creates the 'local' and 'remote' named instances when a function is run (locally) and deployed, respectively. See the .Instances(f) accessor for the map of named environments to these function information structures.
type InstanceRefs ¶
type InstanceRefs struct {
// contains filtered or unexported fields
}
InstanceRefs manager
InstanceRefs are point-in-time snapshots of a function's runtime state in a given environment. By default 'local' and 'remote' environmnts are available when a function is run locally and deployed (respectively).
func (*InstanceRefs) Get ¶
Get the instance data for a function in the named environment. For convenient access to the default 'local' and 'remote' environment see the Local and Remote methods, respectively. Instance returned is populated with a point-in-time snapshot of the function state in the named environment.
func (*InstanceRefs) Local ¶
Local instance details for the function If the function is not running locally the error returned is ErrNotRunning
func (*InstanceRefs) Remote ¶
Remote instance details for the function
Since this is specific to the implicitly available 'remote' environment, the request can be completed with either a name or the local source. Therefore either name or root path can be passed. If name is not passed, the function at root is loaded and its name used for describing the remote instance. Name takes precedence.
type InvokeMessage ¶
type InvokeMessage struct { ID string Source string Type string ContentType string Data string Format string //optional override for function-defined message format }
InvokeMesage is the message used by the convenience method Invoke to provide a simple way to trigger the execution of a function during development.
func NewInvokeMessage ¶
func NewInvokeMessage() InvokeMessage
NewInvokeMessage creates a new InvokeMessage with fields populated
type Job ¶
type Job struct { Function Function Port string Errors chan error // contains filtered or unexported fields }
Job represents a running function job (presumably started by this process' Runner instance.
type Label ¶
type Label struct { // Key consist of optional prefix part (ended by '/') and name part // Prefix part validation pattern: [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)* // Name part validation pattern: ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9] Key *string `` /* 144-byte string literal not displayed */ Value *string `yaml:"value,omitempty" jsonschema:"pattern=^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$"` }
type Lister ¶
type Lister interface { // List the functions currently deployed. List(ctx context.Context) ([]ListItem, error) }
Lister of deployed functions.
type NoopProgressListener ¶
type NoopProgressListener struct{}
ProgressListener
func (*NoopProgressListener) Complete ¶
func (p *NoopProgressListener) Complete(m string)
func (*NoopProgressListener) Done ¶
func (p *NoopProgressListener) Done()
func (*NoopProgressListener) Increment ¶
func (p *NoopProgressListener) Increment(m string)
func (*NoopProgressListener) SetTotal ¶
func (p *NoopProgressListener) SetTotal(i int)
func (*NoopProgressListener) Stopping ¶
func (p *NoopProgressListener) Stopping()
type Option ¶
type Option func(*Client)
Option defines a function which when passed to the Client constructor optionally mutates private members at time of instantiation.
func WithBuilder ¶
WithBuilder provides the concrete implementation of a builder.
func WithDNSProvider ¶
func WithDNSProvider(provider DNSProvider) Option
WithDNSProvider proivdes a DNS provider implementation for registering the effective DNS name which is either explicitly set via WithName or is derived from the root path.
func WithDeployer ¶
WithDeployer provides the concrete implementation of a deployer.
func WithDescriber ¶
WithDescriber provides a concrete implementation of a function describer.
func WithLister ¶
WithLister provides the concrete implementation of a lister.
func WithPipelinesProvider ¶
func WithPipelinesProvider(pp PipelinesProvider) Option
WithPipelinesProvider sets implementation of provider responsible for CI/CD pipelines
func WithProgressListener ¶
func WithProgressListener(p ProgressListener) Option
WithProgressListener provides a concrete implementation of a listener to be notified of progress updates.
func WithPusher ¶
WithPusher provides the concrete implementation of a pusher.
func WithRegistry ¶
WithRegistry sets the default registry which is consulted when an image name is not explicitly provided. Can be fully qualified, including the registry and namespace (ex: 'quay.io/myname') or simply the namespace (ex: 'myname').
func WithRemover ¶
WithRemover provides the concrete implementation of a remover.
func WithRepositoriesPath ¶
WithRepositoriesPath sets the location on disk to use for extensible template repositories. Extensible template repositories are additional templates that exist on disk and are not built into the binary.
func WithRepository ¶
WithRepository sets a specific URL to a Git repository from which to pull templates. This setting's existence precldes the use of either the inbuilt templates or any repositories from the extensible repositories path.
func WithRunner ¶
WithRunner provides the concrete implementation of a deployer.
func WithTransport ¶
func WithTransport(t http.RoundTripper) Option
WithTransport sets a custom transport to use internally.
type Options ¶
type Options struct { Scale *ScaleOptions `yaml:"scale,omitempty"` Resources *ResourcesOptions `yaml:"resources,omitempty"` }
type PipelinesProvider ¶
type PipelinesProvider interface { Run(context.Context, Function) error Remove(context.Context, Function) error ConfigurePAC(context.Context, Function, any) error RemovePAC(context.Context, Function, any) error }
PipelinesProvider manages lifecyle of CI/CD pipelines used by a function
type ProgressListener ¶
type ProgressListener interface { // SetTotal steps of the given task. SetTotal(int) // Increment to the next step with the given message. Increment(message string) // Complete signals completion, which is expected to be somewhat different // than a step increment. Complete(message string) // Stopping indicates the process is in the state of stopping, such as when a // context cancelation has been received Stopping() // Done signals a cessation of progress updates. Should be called in a defer // statement to ensure the progress listener can stop any outstanding tasks // such as synchronous user updates. Done() }
ProgressListener is notified of task progress.
type Pusher ¶
type Pusher interface { // Push the image of the function. // Returns Image Digest - SHA256 hash of the produced image Push(ctx context.Context, f Function) (string, error) }
Pusher of function image to a registry.
type Remover ¶
type Remover interface { // Remove the function from remote. Remove(ctx context.Context, name string) error }
Remover of deployed services.
type Repositories ¶
type Repositories struct {
// contains filtered or unexported fields
}
Repositories manager
func (*Repositories) Add ¶
func (r *Repositories) Add(name, uri string) (string, error)
Add a repository of the given name from the URI. Name, if not provided, defaults to the repo name (sans optional .git suffix). Returns the final name as added.
func (*Repositories) All ¶
func (r *Repositories) All() (repos []Repository, err error)
All repositories under management The default repository is always first. If a path to custom repositories is defined, these are included next. If repositories is in single-repo mode, it will be the only repo returned.
func (*Repositories) Get ¶
func (r *Repositories) Get(name string) (repo Repository, err error)
Get a repository by name, error if it does not exist.
func (*Repositories) List ¶
func (r *Repositories) List() ([]string, error)
List all repositories the current configuration of the repo manager has defined.
func (*Repositories) Path ¶
func (r *Repositories) Path() string
Path returns the currently active repositories path under management. Blank indicates that the system was not instantiated to use any repositories on disk.
func (*Repositories) Remove ¶
func (r *Repositories) Remove(name string) error
Remove a repository of the given name from the repositories. (removes its directory in Path)
func (*Repositories) Rename ¶
func (r *Repositories) Rename(from, to string) error
Rename a repository
type Repository ¶
type Repository struct { // Name of the repository // This can be for instance: // directory name on FS or last part of git URL or arbitrary value defined by the Template author. Name string // Runtimes containing Templates loaded from the repo Runtimes []Runtime // contains filtered or unexported fields }
Repository represents a collection of runtimes, each containing templates.
func NewRepository ¶
func NewRepository(name, uri string) (r Repository, err error)
NewRepository creates a repository instance from any of: a path on disk, a remote or local URI, or from the embedded default repo if uri not provided. Name (optional), if provided takes precedence over name derived from repo at the given URI.
uri (optional), the path either locally or remote from which to load the repository files. If not provided, the internal default is assumed.
func (*Repository) Runtime ¶
func (r *Repository) Runtime(name string) (runtime Runtime, err error)
Runtime of the given name within the repository.
func (*Repository) Template ¶
func (r *Repository) Template(runtimeName, name string) (t Template, err error)
Template from repo for given runtime.
func (*Repository) Templates ¶
func (r *Repository) Templates(runtimeName string) ([]Template, error)
Templates returns the set of all templates for a given runtime. If runtime not found, an empty list is returned.
func (*Repository) URL ¶
func (r *Repository) URL() string
URL attempts to read the remote git origin URL of the repository. Best effort; returns empty string if the repository is not a git repo or the repo has been mutated beyond recognition on disk (ex: removing the origin remote)
func (*Repository) Write ¶
func (r *Repository) Write(dest string) (err error)
Write all files in the repository to the given path.
type ResourcesLimitsOptions ¶
type ResourcesLimitsOptions struct { CPU *string `yaml:"cpu,omitempty" jsonschema:"pattern=^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"` Memory *string `yaml:"memory,omitempty" jsonschema:"pattern=^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"` Concurrency *int64 `yaml:"concurrency,omitempty" jsonschema_extras:"minimum=0"` }
type ResourcesOptions ¶
type ResourcesOptions struct { Requests *ResourcesRequestsOptions `yaml:"requests,omitempty"` Limits *ResourcesLimitsOptions `yaml:"limits,omitempty"` }
type RunSpec ¶
type RunSpec struct { // List of volumes to be mounted to the function Volumes []Volume `yaml:"volumes,omitempty"` // Env variables to be set Envs []Env `yaml:"envs,omitempty"` }
RunSpec
type Runner ¶
type Runner interface { // Run the function, returning a Job with metadata, error channels, and // a stop function.The process can be stopped by running the returned stop // function, either on context cancellation or in a defer. Run(context.Context, Function) (*Job, error) }
Runner runs the function locally.
type Runtime ¶
type Runtime struct { // Name of the runtime Name string // Templates defined for the runtime Templates []Template }
Runtime is a division of templates within a repository of templates for a given runtime (source language plus environmentally available services and libraries)
type ScaleOptions ¶
type ScaleOptions struct { Min *int64 `yaml:"min,omitempty" jsonschema_extras:"minimum=0"` Max *int64 `yaml:"max,omitempty" jsonschema_extras:"minimum=0"` Metric *string `yaml:"metric,omitempty" jsonschema:"enum=concurrency,enum=rps"` Target *float64 `yaml:"target,omitempty" jsonschema_extras:"minimum=0.01"` Utilization *float64 `yaml:"utilization,omitempty" jsonschema:"minimum=1,maximum=100"` }
type Subscription ¶
type Subscription struct { Source string `json:"source" yaml:"source"` Type string `json:"type" yaml:"type"` Broker string `json:"broker" yaml:"broker"` }
Subscriptions currently active to event sources
type Template ¶
type Template interface { // Name of this template. Name() string // Runtime for which this template applies. Runtime() string // Repository within which this template is contained. Value is set to the // currently effective name of the repository, which may vary. It is user- // defined when the repository is added, and can be set to "default" when // the client is loaded in single repo mode. I.e. not canonical. Repository() string // Fullname is a calculated field of [repo]/[name] used // to uniquely reference a template which may share a name // with one in another repository. Fullname() string // Write updates fields of function f and writes project files to path pointed by f.Root. Write(ctx context.Context, f *Function) error }
Template is a function project template. It can be used to instantiate new function project.
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates Manager
func (*Templates) Get ¶
Template returns the named template in full form '[repo]/[name]' for the specified runtime. Templates from the default repository do not require the repo name prefix, though it can be provided.