Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureRunDataDir(root string) error
- func FilesystemFromRepo(uri string) (filesystem.Filesystem, error)
- func Fingerprint(f *Dubbo) (hash, log string, err error)
- func NewErrNotInitialized(path string) error
- type BuildOption
- type BuildOptions
- type BuildSpec
- type Builder
- type Client
- func (c *Client) Build(ctx context.Context, f *Dubbo, options ...BuildOption) (*Dubbo, error)
- func (c *Client) Deploy(ctx context.Context, d *Dubbo, opts ...DeployOption) (*Dubbo, error)
- func (c *Client) Init(cfg *Dubbo, init bool, cmd *cobra.Command) (*Dubbo, error)
- func (c *Client) Push(ctx context.Context, f *Dubbo) (*Dubbo, error)
- func (c *Client) Repositories() *Repositories
- func (c *Client) Runtimes() ([]string, error)
- func (c *Client) Templates() *Templates
- type DeployApp
- type DeployOption
- type DeployParams
- type DeploySpec
- type Deployer
- type DeployerOpt
- type Deployment
- type DeploymentResult
- type Dubbo
- func (f Dubbo) BuildStamp() string
- func (f *Dubbo) Built() bool
- func (f *Dubbo) CheckLabels(ns string, client *Client) error
- func (f *Dubbo) EnsureDockerfile(cmd *cobra.Command) (err error)
- func (f *Dubbo) Initialized() bool
- func (f *Dubbo) Stamp(oo ...stampOption) (err error)
- func (f *Dubbo) Validate() error
- func (f *Dubbo) Write() (err error)
- type Env
- type ErrNotInitialized
- type ErrRunTimeout
- type ErrRunnerNotImplemented
- type ErrRuntimeNotRecognized
- type Label
- type Option
- type Pusher
- 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 Runtime
- type Status
- type Template
- type Templates
Constants ¶
const ( // DubboFile is the file used for the serialized form of a function. DubboFile = "dubbo.yaml" Dockerfile = "Dockerfile" // RunDataDir holds transient runtime metadata // By default it is excluded from source control. RunDataDir = ".dubbo" )
const (
DefaultRepositoryName = "default"
)
const ( // 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 common DefaultTemplate = "common" )
const (
DefaultTemplatesPath = "."
)
Variables ¶
var ( DockerfileGolang = `` /* 853-byte string literal not displayed */ DockerfileJava = `` /* 201-byte string literal not displayed */ DockerfileByRuntime = map[string]string{ "go": DockerfileGolang, "java": DockerfileJava, } )
var ( // ErrTemplateRepoDoesNotExist is a sentinel error if a template repository responds with 404 status code ErrTemplateRepoDoesNotExist = errors.New("template repo does not exist") ErrEnvironmentNotFound = errors.New("environment not found") ErrMismatchedName = errors.New("name passed the function source") ErrNameRequired = errors.New("name required") ErrNotBuilt = errors.New("not built") ErrNotRunning = errors.New("function not running") ErrRepositoriesNotDefined = errors.New("custom template repositories location not specified") ErrRepositoryNotFound = errors.New("repository not found") ErrRootRequired = errors.New("function root path is required") ErrRuntimeNotFound = errors.New("language runtime not found") ErrRuntimeRequired = errors.New("language runtime required") ErrTemplateMissingRepository = errors.New("template name missing repository prefix") ErrTemplateNotFound = errors.New("template not found") ErrTemplatesNotFound = errors.New("templates path (runtimes) not found") ErrContextCanceled = errors.New("the operation was canceled") )
var EmbeddedTemplatesFS = newEmbeddedTemplatesFS()
Functions ¶
func EnsureRunDataDir ¶
EnsureRunDataDir creates a .dubbo directory at the given path, and registers it as ignored in a .gitignore file.
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 Fingerprint ¶
Fingerprint the files at a given path. Returns a hash calculated from the filenames and modification timestamps of the files within the given root. Also returns a logfile consisting of the filenames and modification times which contributed to the hash. Intended to determine if there were appreciable changes to a function's source code, certain directories and files are ignored, such as .git and .dubbo.
func NewErrNotInitialized ¶
Types ¶
type BuildOption ¶
type BuildOption func(c *BuildOptions)
type BuildOptions ¶
type BuildOptions struct{}
type BuildSpec ¶
type BuildSpec struct { // BuilderImages define optional explicit builder images to use by // builder implementations in lea of the in-code defaults. They key // is the builder's short name. For example: // builderImages: // pack: example.com/user/my-pack-node-builder BuilderImages map[string]string `yaml:"builderImages,omitempty"` // Optional list of build-packs to use when building the application Buildpacks []string `yaml:"buildpacks,omitempty"` BuildEnvs []Env `json:"buildEnvs,omitempty"` }
type Builder ¶
type Builder interface { // Build a function project with source located at path. Build(context.Context, *Dubbo) error }
Builder of function source to runnable image.
type Client ¶
type Client struct { KubeCtl *kube.CtlClient // Kube Client // contains filtered or unexported fields }
func (*Client) Build ¶
Build the function at path. Errors if the function is either unloadable or does not contain a populated Image.
func (*Client) Init ¶
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>.
type DeployApp ¶
type DeployApp struct{}
func NewDeployer ¶
func NewDeployer(opts ...DeployerOpt) *DeployApp
func (*DeployApp) Deploy ¶
func (d *DeployApp) Deploy(ctx context.Context, f *Dubbo, option ...DeployOption) (DeploymentResult, error)
type DeployOption ¶
type DeployOption func(f *DeployParams)
type DeployParams ¶
type DeployParams struct {
// contains filtered or unexported fields
}
type DeploySpec ¶
type DeploySpec struct { Namespace string `yaml:"namespace,omitempty"` Output string `yaml:"output,omitempty"` ContainerPort int `yaml:"containerPort,omitempty"` TargetPort int `yaml:"targetPort,omitempty"` NodePort int `yaml:"nodePort,omitempty"` UseProm bool `yaml:"-"` PortName string `yaml:"portName,omitempty"` }
type Deployer ¶
type Deployer interface { // Deploy a function of given name, using given backing image. Deploy(context.Context, *Dubbo, ...DeployOption) (DeploymentResult, error) }
Deployer of function source to running status.
type DeployerOpt ¶
type DeployerOpt func(deployer *DeployApp)
type Deployment ¶
type DeploymentResult ¶
type Dubbo ¶
type Dubbo struct { // Root on disk at which to find/create source and config files. Root string `yaml:"-"` // Name of the application. Name string `yaml:"name,omitempty" jsonschema:"pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"` // Runtime is the language plus context. java|go etc. Runtime string `yaml:"runtime,omitempty"` // Template for the application. Template string `yaml:"template,omitempty"` // 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,omitempty"` // SHA256 hash of the latest image that has been built ImageDigest string `yaml:"-"` // 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,omitempty"` // BuildSpec define the build properties for a function Build BuildSpec `yaml:"build,omitempty"` // DeploySpec define the deployment properties for a function Deploy DeploySpec `yaml:"deploy,omitempty"` }
func NewDubbo ¶
NewDubbo from a given path. Invalid paths, or no function at path are errors. Syntactic errors are returned immediately (yaml unmarshal errors). Dubbo which are syntactically valid are also then logically validated. Dubbo 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 NewDubboWith ¶
NewDubboWith defaults as provided.
func (Dubbo) BuildStamp ¶
BuildStamp accesses the current (last) build stamp for the function. Inbuilt functions return empty string.
func (*Dubbo) Built ¶
Built returns true if the application is considered built. Note that this only considers the application as it exists on-disk at f.Root.
func (*Dubbo) Initialized ¶
Initialized returns if the function has been initialized. Any errors are considered failure (invalid or inaccessible root, config file, etc).
func (*Dubbo) Stamp ¶
Stamp a function as being built.
This is a performance optimization used when updates to the function are known to have no effect on its built container. This stamp is checked before certain operations, and if it has been updated, the build can be skipped. If in doubt, just use .Write only.
Updates the build stamp at ./dubbo/built (and the log at .dubbo/built.log) to reflect the current state of the filesystem. Note that the caller should call .Write first to flush any changes to the application in-memory to the filesystem prior to calling stamp.
The runtime data directory .dubbo is created in the application root if necessary.
type ErrNotInitialized ¶
type ErrNotInitialized struct {
Path string
}
ErrNotInitialized indicates that a function is uninitialized
func (ErrNotInitialized) Error ¶
func (e ErrNotInitialized) Error() string
type ErrRunTimeout ¶
func (ErrRunTimeout) Error ¶
func (e ErrRunTimeout) Error() string
type ErrRunnerNotImplemented ¶
type ErrRunnerNotImplemented struct {
Runtime string
}
ErrRunnerNotImplemented indicates the feature is not available for the requested runtime.
func (ErrRunnerNotImplemented) Error ¶
func (e ErrRunnerNotImplemented) Error() string
type ErrRuntimeNotRecognized ¶
type ErrRuntimeNotRecognized struct {
Runtime string
}
ErrRuntimeNotRecognized indicates a runtime which is not in the set of those known.
func (ErrRuntimeNotRecognized) Error ¶
func (e ErrRuntimeNotRecognized) Error() string
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 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 WithDeployer ¶
func WithKubeClient ¶
func WithPusher ¶
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.
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 *Dubbo) (string, error) }
Pusher of function image to a registry.
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)
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 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 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 *Dubbo) 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