client

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package client contains all the business logic of the command line deployment tool. It knows how to talk to Habitat and the grpc client to communicate with the server.

Index

Constants

View Source
const (
	// Waiting status means we haven't started a deploy, a phase,
	// or a phase step
	Waiting api.DeployEvent_Status = api.DeployEvent_WAITING

	// Running status means we are in progress with a deploy, a
	// phase, or a phase step
	Running api.DeployEvent_Status = api.DeployEvent_RUNNING

	// CompleteOk status means a deploy, phase, or phase step
	// finished successfully.
	CompleteOk api.DeployEvent_Status = api.DeployEvent_COMPLETE_OK

	// CompleteFail status means that a deploy, phase, or phase
	// step ran and failed.
	CompleteFail api.DeployEvent_Status = api.DeployEvent_COMPLETE_FAIL
)
View Source
const DefaultClientTimeout = 1 * time.Second

DefaultClientTimeout is the timeout duration to use when initializing the Connection in the context of a command that does basic API queries

View Source
const DefaultDeployTimeout = 5 * time.Second

DefaultDeployTimeout is the timeout duration to use when initializing the Connection in the context of a command that deploys things

View Source
const ServiceAddressKey = "DEPLOYMENT_SERVICE_ADDRESS"

ServiceAddressKey is the env variable key for service address

Variables

This section is empty.

Functions

func A1ExtractUserData

func A1ExtractUserData(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error

A1ExtractUserData runs the A1 user data extraction portion of the A1 migration process.

func A1ExtractUserRolesData

func A1ExtractUserRolesData(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error

A1ExtractUserRolesData runs the A1 user data extraction portion of the A1 migration process.

func A1PgDump

func A1PgDump(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error

A1PgDump runs the PGDump portion of the A1 migration process. It is used to create a1migration data artifacts.

func A1Upgrade

func A1Upgrade(writer cli.FormatWriter,
	upgrade *a1upgrade.A1Upgrade,
	acceptDefaults bool,
	manifestProvider manifest.ReleaseManifestProvider,
	cliVersion string,
	airgap bool,
) error

A1Upgrade bootstraps the system, copies/moves a1 data to a2, and then installs a2

func BackupStatus

func BackupStatus(conTimeout, reqTimeout time.Duration) (*api.BackupStatusResponse, error)

BackupStatus makes a gRPC request to the deployment-service for the backup runner status

func CLIUpToDateWithLatestManifest

func CLIUpToDateWithLatestManifest(hartifactsPath, overrideOrigin, channel, version string) error

func CancelBackup

func CancelBackup(conTimeout, reqTimeout time.Duration) (*api.CancelBackupResponse, error)

CancelBackup makes a gRPC request to the deployment-service and cancels the the running backup operation

func CreateBackup

func CreateBackup(conTimeout, reqTimeout time.Duration, _ cli.FormatWriter) (*api.CreateBackupResponse, error)

CreateBackup makes a gRPC request to the deployment service to start a new backup create routine. The server returns a backup ID which can be used to stream backup events.

func DeleteBackups

func DeleteBackups(conTimeout, reqTimeout time.Duration, ids []*api.BackupTask) (*api.DeleteBackupsResponse, error)

DeleteBackups makes a gRPC request to the deployment service to start a new backup create routine. The server returns a backup ID which can be used to stream backup events.

func Deploy

func Deploy(writer cli.FormatWriter,
	overrideConfig *dc.AutomateConfig,
	skipPreflight bool,
	manifestProvider manifest.ReleaseManifestProvider,
	cliVersion string,
	airgap bool) error

Deploy bootstraps the system and then installs Chef Automate v2

func Destroy

func Destroy(writer cli.FormatWriter, opts UninstallOpts) error

func DevA1Backup

func DevA1Backup(w cli.FormatWriter, u *a1upgrade.A1Upgrade) error

DevA1Backup runs just the the backup part of an upgrade. This is exposed so we can use it in dev CLI tooling to verify backups function correctly. TODO: Investigate if we should rm this function

func Disconnect

func Disconnect()

func GetAddress

func GetAddress() (string, error)

GetAddress fetches the service address from an env variable

func GetAutomateConfig

func GetAutomateConfig(timeout int64) (*api.GetAutomateConfigResponse, error)

GetAutomateConfig makes a gRPC request to the server and returns the userOverrideConfig.

func GetHostPort

func GetHostPort() (string, string, error)

GetHostPort does some validation on the address and splits it into host and port, respectively

func ListBackups

func ListBackups(conTimeout, reqTimeout time.Duration) (*api.ListBackupsResponse, error)

ListBackups makes a gRPC request to the deployment service to list available backups.

func PatchAutomateConfig

func PatchAutomateConfig(timeout int64, config *dc.AutomateConfig, writer cli.FormatWriter) error

PatchAutomateConfig makes a gRPC request to the server with a given userOverrideConfig. The server will validate, merge, and persist the configuration. After it it persisted it will start a converge task and return the task ID to the client. It then streams the converge events to the given writer.

func Preflight

func Preflight(writer cli.FormatWriter,
	overrideCfg *dc.AutomateConfig,
	cliVersion string,
	airgap bool) error

Preflight runs preflight checks for the pure install case

func RestoreBackup

func RestoreBackup(conTimeout, reqTimeout time.Duration, restoreTask *api.BackupRestoreTask) (*api.RestoreBackupResponse, error)

RestoreBackup makes a gRPC request to the deployment service to start a new backup restore routine. The server returns a restore ID which can be used to stream backup events.

func SetAutomateConfig

func SetAutomateConfig(timeout int64, config *dc.AutomateConfig, writer cli.FormatWriter) error

SetAutomateConfig makes a gRPC request to the server with a given userOverrideConfig. The server will validate, set, and persist the configuration. After it it persisted it will start a converge task and return the task ID to the client. It then streams the converge events to the given writer.

func SetProxyEnvironment

func SetProxyEnvironment(config *dc.ConfigRequest)

SetProxyEnvironment sets the http_proxy and no_proxy environment variables based on the given configuration request.

func ShowBackup

func ShowBackup(conTimeout, reqTimeout time.Duration, id *api.BackupTask) (*api.ShowBackupResponse, error)

ShowBackup makes a gRPC request to the deployment service to list available backups.

func StreamBackupStatus

func StreamBackupStatus(conTimeout, reqTimeout time.Duration, taskID string, writer cli.FormatWriter) (*api.DeployEvent, error)

StreamBackupStatus makes a gRPC request to the deployment service and streams deployment events for a task to a backup event handler.

func WarnIfNotUpToDateAgainstServer

func WarnIfNotUpToDateAgainstServer(connection ManifestVersionClient, writer WarningWriter, version string)

WarnIfNotUpToDateAgainstServer warns if deployment services indicates a newer cli version is available than what is being used. Also warns if errors happen talking to deployment service

Types

type CLIEventWriter

type CLIEventWriter struct {
	Writer cli.FormatWriter
}

CLIEventWriter is an implementation of DeployEventHandler that writes the events to the terminal

func (*CLIEventWriter) HandleEvent

func (ew *CLIEventWriter) HandleEvent(event *api.DeployEvent)

HandleEvent implements the DeployEventHandler contract by writing the events to the terminal.

type ConnOpt

type ConnOpt func(c *connectOptions)

A ConnOpt is a connection option that can be passed to the Connection function.

type DSClient

DSClient multiplexes the various clients that the deployment-service can serve.

func Connection

func Connection(connectTimeout time.Duration, opts ...ConnOpt) (*DSClient, error)

Connection creates (if necessary) a gRPC connection to the deployment service, saves it, and returns it.

func NewDSClient

func NewDSClient(c *grpc.ClientConn) *DSClient

type DeploymentRestore

type DeploymentRestore struct {
	// contains filtered or unexported fields
}

DeploymentRestore represents a local deployment-service restoration.

func NewDeploymentRestore

func NewDeploymentRestore(opts ...DeploymentRestoreOpt) *DeploymentRestore

NewDeploymentRestore returns a new instance of DeploymentRestore

func (*DeploymentRestore) Restore

func (r *DeploymentRestore) Restore() error

Restore bootstraps the deployment-service and restores the backup

type DeploymentRestoreOpt

type DeploymentRestoreOpt func(*DeploymentRestore)

DeploymentRestoreOpt represents an optional configuration function for a DeploymentRestore.

func WithDeploymentRestoreAirgapInstallBundle

func WithDeploymentRestoreAirgapInstallBundle(airgapInstallBundlePath string) DeploymentRestoreOpt

func WithDeploymentRestoreSkipBootstrap

func WithDeploymentRestoreSkipBootstrap(skip bool) DeploymentRestoreOpt

WithDeploymentRestoreSkipBootstrap determines whether or not to skip bootstrapping Habitat from the manifest during a restore.

func WithDeploymentRestoreSkipPreflight

func WithDeploymentRestoreSkipPreflight(skip bool) DeploymentRestoreOpt

WithDeploymentRestoreSkipPreflight determines whether or not to skip preflight checks when restoring a backup.

func WithDeploymentRestoreTask

func WithDeploymentRestoreTask(task *api.BackupRestoreTask) DeploymentRestoreOpt

WithDeploymentRestoreTask sets restore task for the deployment restore

func WithDeploymentRestoreWriter

func WithDeploymentRestoreWriter(writer cli.FormatWriter) DeploymentRestoreOpt

WithDeploymentRestoreWriter sets the writer to use for CLI I/O

type ManifestVersionClient

type ManifestVersionClient interface {
	ManifestVersion(ctx context.Context, in *api.ManifestVersionRequest, opts ...grpc.CallOption) (*api.ManifestVersionResponse, error)
}

ManifestVersionClient is a client that implements the ManifestVersion client

type UninstallOpts

type UninstallOpts struct {
	Yes              bool
	PreservePkgCache bool
}

type WarningWriter

type WarningWriter interface {
	Warn(string)
	Warnf(m string, f ...interface{})
	WarnError(error)
}

WarningWriter is an interface that we use to warn about version mismatches

Jump to

Keyboard shortcuts

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