Documentation
¶
Overview ¶
Package core provides the verless business logic.
Each verless sub-command maintains its own file in the core package, like build.go for `verless build`. This file provides a function in the form Run<Sub-Command>, e.g. RunBuild, serving as an entry point for other packages.
Sub-commands of sub-commands like `verless create project` don't require an own file, they can just be grouped together in a common file like create.go.
An entry point function either implements the business logic itself like RunVersion does, or prepares components and passes them to an inner core package for more complex scenarios.
Typically, a verless command has multiple options. These options are types in the core package, declared in the command's file. They have to be initialized by the caller - for example the cli package - and then passed to the entry point function. The name of an option type must be in the form <Sub-Command>Options like BuildOptions. Options for sub-commands of sub-commands like `verless create project` must have a name in the form <Sub-Command><Sub-Command>Options, like CreateProjectOptions.
As a result, most entry point functions accept a dedicated options instance. Some of them also require an initialized config instance or fixed command line arguments - see RunBuild as an example.
Core functions typically shouldn't have outgoing dependencies except for dependencies like the fs or model packages. Instead, they should define their dependencies as interfaces which can be implemented by outside packages. A good example for this is build.Parser implemented by parser.Markdown.
It is the entry point function's job to initialize those external dependencies, like calling parser.NewMarkdown, and passing it to the particular core function. Again, RunBuild is good example for this.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCannotOverwrite states that verless isn't allowed to // delete or overwrite the output directory. ErrCannotOverwrite = errors.New(`Cannot overwrite the output directory. Consider using the --overwrite flag or enabled build.overwrite in the configuration file.`) )
Functions ¶
func RunBuild ¶
func RunBuild(path string, options BuildOptions, cfg config.Config) []error
RunBuild triggers a build using the provided options and user configuration.
See doc.go for more information on the core architecture.
func RunCreateProject ¶
func RunCreateProject(path string, options CreateProjectOptions) error
RunCreateProject creates a new verless project. If the specified project path already exists, RunCreateProject returns an error unless --overwrite has been used.
func RunVersion ¶
func RunVersion(options VersionOptions) error
RunVersion prints verless version information.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
// OutputDir sets the output directory. If this field is empty,
// config.OutputDir will be used.
OutputDir string
// Overwrite specifies that the output folder can be overwritten.
Overwrite bool
}
BuildOptions represents options for running a verless build.
type CreateProjectOptions ¶
type CreateProjectOptions struct {
Overwrite bool
}
CreateProjectOptions represents options for creating a new verless project.
type VersionOptions ¶
type VersionOptions struct {
// Quiet only prints the plain version number.
Quiet bool
}
VersionOptions represents options for the version command.