client

package
v0.11.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package client contains the Waypoint client implementation.

The Waypoint client exposes a slightly higher level of abstraction than direct a API client for performing operations on an application. The primary consumer of this package is the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestApp

func TestApp(t testing.T, c *Project) string

TestApp returns an app reference that can be used for testing.

Types

type App

type App struct {
	UI terminal.UI
	// contains filtered or unexported fields
}

App is used for application-specific operations.

func (*App) Auth

func (c *App) Auth(ctx context.Context, op *pb.Job_AuthOp) (*pb.Job_AuthResult, error)

func (*App) Build

func (c *App) Build(ctx context.Context, op *pb.Job_BuildOp) (*pb.Job_BuildResult, error)

func (*App) ConfigSync added in v0.2.0

func (c *App) ConfigSync(ctx context.Context, op *pb.Job_ConfigSyncOp) (*pb.Job_Result, error)

func (*App) Deploy

func (c *App) Deploy(ctx context.Context, op *pb.Job_DeployOp) (*pb.Job_DeployResult, error)

func (*App) Destroy

func (c *App) Destroy(ctx context.Context, op *pb.Job_DestroyOp) error

func (*App) Docs

func (c *App) Docs(ctx context.Context, op *pb.Job_DocsOp) (*pb.Job_DocsResult, error)

func (*App) Exec added in v0.3.0

func (c *App) Exec(ctx context.Context, ec *execclient.Client) (exitCode int, err error)

func (*App) Logs

func (a *App) Logs(ctx context.Context, deploySeq string) (pb.Waypoint_GetLogStreamClient, error)

func (*App) Noop

func (c *App) Noop(ctx context.Context) error

Noop executes a noop operation. This is primarily for testing but is exported since it has its uses in verifying a runner is functioning properly.

A noop operation will exercise the full logic of queueing a job, assigning it to a runner, dequeueing as a runner, executing, etc. It will use real remote runners if the client is configured to do so.

func (*App) PushBuild

func (c *App) PushBuild(ctx context.Context, op *pb.Job_PushOp) error

func (*App) Ref

func (c *App) Ref() *pb.Ref_Application

Ref returns the application reference that this client is using.

func (*App) Release

func (c *App) Release(ctx context.Context, op *pb.Job_ReleaseOp) (*pb.Job_ReleaseResult, error)

func (*App) StatusReport added in v0.4.0

func (c *App) StatusReport(ctx context.Context, op *pb.Job_StatusReportOp) (*pb.Job_StatusReportResult, error)

func (*App) Up added in v0.3.0

func (c *App) Up(ctx context.Context, op *pb.Job_UpOp) (*pb.Job_Result, error)

type Option

type Option func(*Project, *config) error

func WithClient

func WithClient(client pb.WaypointClient) Option

WithClient sets the client directly. In this case, the runner won't attempt any connection at all regardless of other configuration (env vars or waypoint config file). This will be used.

If this is specified, the client MUST use a tokenutil.ContextToken type for the PerRPCCredentials setting. This package and others will use context overrides for the token. If you do not use this, things will break.

func WithClientConnect

func WithClientConnect(opts ...serverclient.ConnectOption) Option

WithClientConnect specifies the options for connecting to a client. If WithClient is specified, that client is always used.

If WithLocal is set and no client is specified and no server creds can be found, then an in-process server will be created.

func WithConfig added in v0.7.2

func WithConfig(waypointHCL *configpkg.Config) Option

WithConfig sets the config file (waypoint.hcl) and path.

func WithLabels

func WithLabels(m map[string]string) Option

WithLabels sets the labels or any operations.

func WithLogger

func WithLogger(log hclog.Logger) Option

WithLogger sets the logger for the client.

func WithNoLocalServer added in v0.7.0

func WithNoLocalServer() Option

WithNoLocalServer prevents the project client from automatically creating a local server.

func WithProjectRef

func WithProjectRef(ref *pb.Ref_Project) Option

WithProjectRef sets the project reference for all operations performed.

func WithSourceOverrides

func WithSourceOverrides(m map[string]string) Option

WithSourceOverrides sets the data source overrides for queued jobs.

func WithUI

func WithUI(ui terminal.UI) Option

WithUI sets the UI to use for the client.

func WithUseLocalRunner added in v0.7.0

func WithUseLocalRunner(useLocalRunner bool) Option

WithUseLocalRunner instructs this client to execute all jobs either on a local runner, or on a remote runner. If unset, it will automatically determine where jobs will execute, preferring remote when possible

func WithVariables added in v0.5.0

func WithVariables(m []*pb.Variable) Option

WithVariables sets variable values from flags and local env on any operations.

func WithWorkspaceRef

func WithWorkspaceRef(ref *pb.Ref_Workspace) Option

WithWorkspaceRef sets the workspace reference for all operations performed. If this isn't set, the default workspace will be used.

type Project

type Project struct {
	UI terminal.UI
	// contains filtered or unexported fields
}

Project is the primary structure for interacting with a Waypoint server as a client. The client exposes a slightly higher level of abstraction over the server API for performing operations locally and remotely.

func New

func New(ctx context.Context, opts ...Option) (*Project, error)

New initializes a new client.

func TestProject

func TestProject(t testing.T, opts ...Option) *Project

TestProject returns an initialized client pointing to an in-memory test server. This will close automatically on test completion.

This will also change the working directory to a temporary directory so that any side effect file creation doesn't impact the real working directory. If you need to use your working directory, query it before calling this.

func (*Project) App

func (c *Project) App(n string) *App

App returns the app-specific operations client.

func (*Project) Client

func (c *Project) Client() pb.WaypointClient

Client returns the raw Waypoint server API client.

func (*Project) Close

func (c *Project) Close() error

Close should be called to clean up any resources that the client created.

func (*Project) DestroyProject added in v0.10.0

func (*Project) DoJobDangerously added in v0.10.0

func (c *Project) DoJobDangerously(ctx context.Context, job *pb.Job) (*pb.Job_Result, error)

DoJobDangerously executes the given job and returns the result. The "Dangerously" suffix is because this function isn't meant to be generally used; it is dangerous because it doesn't perform many validation steps. In almost all cases, callers should use a more focused function such as Build or Deploy, or write a new one.

func (*Project) Local

func (c *Project) Local() bool

Local is true if the server is an in-process just-in-time server.

func (*Project) LocalRunnerId added in v0.3.0

func (c *Project) LocalRunnerId() (string, bool)

LocalRunnerId returns the id of the runner that this project started This is used to target jobs specifically at this runner.

func (*Project) Ref

func (c *Project) Ref() *pb.Ref_Project

Ref returns the raw Waypoint server API client.

func (*Project) ServerVersion added in v0.3.1

func (c *Project) ServerVersion() *pb.VersionInfo

ServerVersion returns the server version that this client is connected to.

func (*Project) Validate

func (c *Project) Validate(ctx context.Context, op *pb.Job_ValidateOp) (*pb.Job_ValidateResult, error)

func (*Project) WorkspaceRef

func (c *Project) WorkspaceRef() *pb.Ref_Workspace

WorkspaceRef returns the application reference that this client is using.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL