Documentation
¶
Overview ¶
Package core exposes a high-level API for the expected operations of the project. This can be consumed by the CLI, web APIs, etc. This is the safest set of APIs to use.
The entrypoint for core is Project initialized with NewProject. All further APIs and operations hang off of this struct. For example, to initiate a build for an app in a project you could use Project.App.Build().
Eventually this package will also contain UI abstractions or hooks so that you can build a more responsive UI around the long-running operations of this package.
Index ¶
- func TestFactory(t testing.T, typ component.Type) *factory.Factory
- func TestFactoryRegister(t testing.T, f *factory.Factory, n string, v interface{})
- func TestFactorySingle(t testing.T, typ component.Type, n string) (*factory.Factory, *mock.Mock)
- type App
- func (a *App) Auth(ctx context.Context, c interface{}) (*component.AuthResult, error)
- func (a *App) Build(ctx context.Context, optFuncs ...BuildOption) (*pb.Build, *pb.PushedArtifact, error)
- func (a *App) CanAuth(comp interface{}) bool
- func (a *App) CanDestroyDeploy() bool
- func (a *App) CanDestroyRelease() bool
- func (a *App) Close() error
- func (a *App) ComponentProto(c interface{}) *pb.Component
- func (a *App) Components() []interface{}
- func (a *App) Deploy(ctx context.Context, push *pb.PushedArtifact) (*pb.Deployment, error)
- func (a *App) Destroy(ctx context.Context) error
- func (a *App) DestroyDeploy(ctx context.Context, d *pb.Deployment) error
- func (a *App) DestroyRelease(ctx context.Context, d *pb.Release) error
- func (a *App) PushBuild(ctx context.Context, optFuncs ...PushBuildOption) (*pb.PushedArtifact, error)
- func (a *App) Ref() *pb.Ref_Application
- func (a *App) Release(ctx context.Context, target *pb.Deployment) (*pb.Release, component.Release, error)
- func (a *App) ValidateAuth(ctx context.Context, c interface{}) error
- type BuildOption
- type Option
- func WithClient(client pb.WaypointClient) Option
- func WithComponents(fs map[component.Type]*factory.Factory) Option
- func WithConfig(c *config.Config) Option
- func WithConfigContext(ctx *hcl.EvalContext) Option
- func WithDataDir(dir *datadir.Project) Option
- func WithFactory(t component.Type, f *factory.Factory) Option
- func WithJobInfo(info *component.JobInfo) Option
- func WithLabels(m map[string]string) Option
- func WithLogger(log hclog.Logger) Option
- func WithMappers(m ...*argmapper.Func) Option
- func WithRootDir(dir string) Option
- func WithUI(ui terminal.UI) Option
- func WithWorkspace(ws string) Option
- type Project
- type PushBuildOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestFactory ¶
TestFactory creates a factory for the given component type.
func TestFactoryRegister ¶
TestFactoryRegister registers a singleton value to be returned for the factory for the name n.
func TestFactorySingle ¶
TestFactorySingle creates a factory for the given component type and registers a single implementation and returns that mock. This is useful to create a factory for the WithFactory option that returns a mocked value that can be tested against.
Types ¶
type App ¶
type App struct { Builder component.Builder Registry component.Registry Platform component.Platform Releaser component.ReleaseManager // UI is the UI that should be used for any output that is specific // to this app vs the project UI. UI terminal.UI // contains filtered or unexported fields }
App represents a single application and exposes all the operations that can be performed on an application.
An App is only valid if it was returned by Project.App. The behavior of App if constructed in any other way is undefined and likely to result in crashes.
func (*App) Auth ¶
Auth authenticates a component. This will return an error if the component doesn't support auth. If this returns nil, then the auth function succeeded but the component itself may still not be authenticated. You must check again with ValidateAuth.
func (*App) Build ¶
func (a *App) Build(ctx context.Context, optFuncs ...BuildOption) ( *pb.Build, *pb.PushedArtifact, error, )
Build builds the artifact from source for this app. TODO(mitchellh): test
func (*App) CanAuth ¶
CanAuth returns true if the provided component supports authenticating and validating authentication for plugins
func (*App) CanDestroyDeploy ¶
CanDestroyDeploy returns true if this app supports destroying deployments.
func (*App) CanDestroyRelease ¶
CanDestroyRelease returns true if this app supports destroying releases.
func (*App) Close ¶
Close is called to clean up any resources. This should be called whenever the app is done being used. This will be called by Project.Close.
func (*App) ComponentProto ¶
ComponentProto returns the proto info for a component. The passed component must be part of the app or nil will be returned.
func (*App) Components ¶
func (a *App) Components() []interface{}
Components returns the list of components that were initilized for this app.
func (*App) Deploy ¶
func (a *App) Deploy(ctx context.Context, push *pb.PushedArtifact) (*pb.Deployment, error)
Deploy deploys the given artifact. TODO(mitchellh): test
func (*App) Destroy ¶
Destroy will destroy all the physical resources for this app in the current configured workspace. If this returns an error, it is possible that the destroy is in a partial state.
func (*App) DestroyDeploy ¶
DestroyDeploy destroyes a specific deployment.
func (*App) DestroyRelease ¶
DestroyRelease destroyes a specific release.
func (*App) PushBuild ¶
func (a *App) PushBuild(ctx context.Context, optFuncs ...PushBuildOption) (*pb.PushedArtifact, error)
Push pushes the given build to the configured registry. This requires that the build artifact be available, which we leave up to the caller. Therefore, please note that this generally can't be called on separate machines, long after a build is done (because the person may have deleted the physical artifact, etc.).
TODO(mitchellh): test
func (*App) Ref ¶
func (a *App) Ref() *pb.Ref_Application
Ref returns the reference to this application for us in API calls.
type BuildOption ¶
type BuildOption func(*buildOptions) error
BuildOption is used to configure a Build
func BuildWithPush ¶
func BuildWithPush(v bool) BuildOption
BuildWithPush sets whether or not the build will push. The default is for the build to push.
type Option ¶
type Option func(*Project, *options)
Option is used to set options for NewProject.
func WithClient ¶
func WithClient(client pb.WaypointClient) Option
WithClient sets the API client to use.
func WithComponents ¶
WithComponents sets the factories for components.
func WithConfig ¶
WithConfig uses the given project configuration for initializing the Project. This configuration must be validated already prior to using this option.
func WithConfigContext ¶
func WithConfigContext(ctx *hcl.EvalContext) Option
WithConfigContext sets an eval context to use for parsing plugin-specific config. It is useful to reuse the same context that was used in parsing the original config here so behavior doesn't change.
func WithDataDir ¶
WithDataDir sets the datadir that will be used for this project.
func WithFactory ¶
WithFactory sets a factory for a component type. If this isn't set for any component type, then the builtin mapper will be used.
func WithJobInfo ¶
WithJobInfo sets the base job info used for any executed operations.
func WithLabels ¶
WithLabels sets the labels that will override any other labels set.
func WithLogger ¶
func WithLogger(log hclog.Logger) Option
WithLogger sets the logger to use with the project. If this option is not provided, a default logger will be used (`hclog.L()`).
func WithMappers ¶
func WithMappers(m ...*argmapper.Func) Option
WithMappers adds the mappers to the list of mappers.
func WithRootDir ¶
WithRootDir sets the root directory for the project. This is where the root configuration is.
func WithWorkspace ¶
WithWorkspace sets the workspace we'll be working in.
type Project ¶
type Project struct { // UI is the terminal UI to use for messages related to the project // as a whole. These messages will show up unprefixed for example compared // to the app-specific UI. UI terminal.UI // contains filtered or unexported fields }
Project represents a project with one or more applications.
The Close function should be called when finished with the project to properly clean up any open resources.
func NewProject ¶
NewProject creates a new Project with the given options.
func TestProject ¶
TestProject returns a fully in-memory and side-effect free Project that can be used for testing. Additional options can be given to provide your own factories, configuration, etc.
func (*Project) Client ¶
func (p *Project) Client() pb.WaypointClient
Client returns the API client for the backend server.
func (*Project) Close ¶
Close is called to clean up resources allocated by the project. This should be called and blocked on to gracefully stop the project.
func (*Project) Ref ¶
func (p *Project) Ref() *pb.Ref_Project
Ref returns the project ref for API calls.
func (*Project) WorkspaceRef ¶
func (p *Project) WorkspaceRef() *pb.Ref_Workspace
WorkspaceRef returns the project ref for API calls.
type PushBuildOption ¶
type PushBuildOption func(*pushBuildOptions) error
PushBuildOption is used to configure a Build
func PushWithBuild ¶
func PushWithBuild(b *pb.Build) PushBuildOption
BuildWithPush sets whether or not the build will push. The default is for the build to push.