Documentation ¶
Index ¶
- Constants
- Variables
- func DerivedImage(root, registry string) (image string, err error)
- func ValidateEnvs(envs Envs) (errors []string)
- type Builder
- type Client
- func (c *Client) Build(ctx context.Context, path string) (err error)
- func (c *Client) Create(cfg Function) (err error)
- func (c *Client) Deploy(ctx context.Context, path string) (err error)
- func (c *Client) Describe(ctx context.Context, name, root string) (d Description, err error)
- func (c *Client) Emit(ctx context.Context, endpoint string) error
- func (c *Client) List(ctx context.Context) ([]ListItem, error)
- func (c *Client) New(ctx context.Context, cfg Function) (err error)
- func (c *Client) Remove(ctx context.Context, cfg Function) error
- func (c *Client) Route(path string) (err error)
- func (c *Client) Run(ctx context.Context, root string) error
- type DNSProvider
- type Deployer
- type DeploymentResult
- type Describer
- type Description
- type Emitter
- type Env
- type Envs
- type Function
- type ListItem
- type Lister
- type Option
- func WithBuilder(d Builder) Option
- func WithDNSProvider(provider DNSProvider) Option
- func WithDeployer(d Deployer) Option
- func WithDescriber(describer Describer) Option
- func WithEmitter(e Emitter) Option
- func WithLister(l Lister) Option
- func WithProgressListener(p ProgressListener) Option
- func WithPusher(d Pusher) Option
- func WithRegistry(registry string) Option
- func WithRemover(r Remover) Option
- func WithRepositories(repositories string) Option
- func WithRunner(r Runner) Option
- func WithVerbose(v bool) Option
- type Options
- type ProgressListener
- type Pusher
- type Remover
- type ResourcesLimitsOptions
- type ResourcesOptions
- type ResourcesRequestsOptions
- type Runner
- type ScaleOptions
- type Status
- type Subscription
- type Volume
- type Volumes
Constants ¶
const ( DefaultRegistry = "docker.io" DefaultRuntime = "node" // DefautlTemplate is the default Function signature / environmental context // of the resultant function. All runtimes are expected to have at least // one implementation of each supported funciton sinagure. Currently that // includes an HTTP Handler ("http") and Cloud Events handler ("events") DefaultTemplate = "http" )
const ConfigFile = "func.yaml"
ConfigFile is the name of the config's serialized form.
Variables ¶
var ( ErrRepositoryNotFound = errors.New("repository not found") ErrRepositoriesNotDefined = errors.New("custom template repositories location not specified") ErrRuntimeNotFound = errors.New("runtime not found") ErrTemplateNotFound = errors.New("template not found") ErrTemplateMissingRepository = errors.New("template name missing repository prefix") )
var ErrNotBuilt = errors.New("not built")
ErrNotBuilt indicates the Function has not yet been built.
Functions ¶
func DerivedImage ¶
DerivedImage returns the derived image name (OCI container tag) of the Function whose source is at root, with the default registry for when the image has to be calculated (derived). The following are eqivalent due to the use of DefaultRegistry: registry: docker.io/myname
myname
A full image name consists of registry, image name and tag. in form [registry]/[image-name]:[tag] example docker.io/alice/my.example.func:latest Default if not provided is --registry (a required global setting) followed by the provided (or derived) image name.
func ValidateEnvs ¶ added in v0.16.0
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
Types ¶
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) Build ¶
Build the Function at path. Errors if the Function is either unloadable or does not contain a populated Image.
func (*Client) Create ¶
Create a new Function project locally using the settings provided on a Function object.
func (*Client) Deploy ¶
Deploy the Function at path. Errors if the Function has not been initialized with an image tag.
func (*Client) Describe ¶
Describe a Function. Name takes precidence. If no name is provided, the Function defined at root is used.
func (*Client) New ¶
New Function. Use Create, Build and Deploy independently for lower level control.
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 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 ¶ added in v0.13.0
type Describer ¶
type Describer interface { // Describe the running state of the service as reported by the underlyng platform. Describe(ctx context.Context, name string) (description Description, err error) }
Describer of Functions' remote deployed aspect.
type Description ¶
type Description struct { Name string `json:"name" yaml:"name"` Image string `json:"image" yaml:"image"` Namespace string `json:"namespace" yaml:"namespace"` Routes []string `json:"routes" yaml:"routes"` Subscriptions []Subscription `json:"subscriptions" yaml:"subscriptions"` }
type Function ¶
type Function struct { // Root on disk at which to find/create source and config files. Root string // Name of the Function. If not provided, path derivation is attempted when // requried (such as for initialization). Name string // Namespace into which the Function is deployed on supported platforms. Namespace string // Runtime is the language plus context. nodejs|go|quarkus|rust etc. Runtime string // Template for the Function. Template string // Registry at which to store interstitial containers, in the form // [registry]/[user]. If omitted, "Image" must be provided. Registry string // 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 // SHA256 hash of the latest image that has been built ImageDigest string // Builder represents the CNCF Buildpack builder image for a function, // or it might be reference to `BuilderMap`. Builder string // Map containing known builders. // e.g. { "jvm": "docker.io/example/quarkus-jvm-builder" } BuilderMap map[string]string // List of volumes to be mounted to the function Volumes Volumes // Env variables to be set Envs Envs // Map containing user-supplied annotations // Example: { "division": "finance" } Annotations map[string]string // Options to be set on deployed function (scaling, etc.) Options Options }
func NewFunction ¶
NewFunction loads a Function from a path on disk. use .Initialized() to determine if the path contained an initialized Function. NewFunction creates a Function struct whose attributes are loaded from the configuraiton located at path.
func (Function) Built ¶ added in v0.12.0
Built indicates the Function has been built. Does not guarantee the image indicated actually exists, just that it _should_ exist based off the current state of the Funciton object, in particular the value of the Image and ImageDiget fields.
func (Function) ImageWithDigest ¶
ImageWithDigest returns the full reference to the image including SHA256 Digest. If Digest is empty, image:tag is returned.
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) WriteConfig ¶
WriteConfig writes this Function's configuration to disk.
type Lister ¶
type Lister interface { // List the Functions currently deployed. List(ctx context.Context) ([]ListItem, error) }
Lister of deployed services.
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 WithEmitter ¶ added in v0.15.0
WithEmitter sets a CloudEvent emitter on the client which is capable of sending a CloudEvent to an arbitrary function endpoint
func WithLister ¶
WithLister provides the concrete implementation of a lister.
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/tag is not explocitly provided. Can be fully qualified, including the registry (ex: 'quay.io/myname') or simply the namespace 'myname' which indicates the the use of the default registry.
func WithRemover ¶
WithRemover provides the concrete implementation of a remover.
func WithRepositories ¶ added in v0.16.0
WithRepositories sets the location to use for extensible template repositories. Extensible template repositories are additional templates that exist on disk and are not built into the binary.
func WithRunner ¶
WithRunner provides the concrete implementation of a deployer.
type Options ¶ added in v0.16.0
type Options struct { Scale *ScaleOptions `yaml:"scale,omitempty"` Resources *ResourcesOptions `yaml:"resources,omitempty"` }
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) // 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 ResourcesLimitsOptions ¶ added in v0.16.0
type ResourcesOptions ¶ added in v0.16.0
type ResourcesOptions struct { Requests *ResourcesRequestsOptions `yaml:"requests,omitempty"` Limits *ResourcesLimitsOptions `yaml:"limits,omitempty"` }