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
- func A1ExtractUserData(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error
- func A1ExtractUserRolesData(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error
- func A1PgDump(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade) error
- func A1Upgrade(writer cli.FormatWriter, upgrade *a1upgrade.A1Upgrade, acceptDefaults bool, ...) error
- func BackupIntegrityShow(conTimeout, reqTimeout time.Duration) (*api.BackupIntegrityShowResponse, error)
- func BackupStatus(conTimeout, reqTimeout time.Duration) (*api.BackupStatusResponse, error)
- func CLIUpToDateWithLatestManifest(hartifactsPath, overrideOrigin, channel, version string) error
- func CancelBackup(conTimeout, reqTimeout time.Duration) (*api.CancelBackupResponse, error)
- func CreateBackup(conTimeout, reqTimeout time.Duration, _ cli.FormatWriter) (*api.CreateBackupResponse, error)
- func DeleteBackups(conTimeout, reqTimeout time.Duration, ids []*api.BackupTask) (*api.DeleteBackupsResponse, error)
- func Deploy(writer cli.FormatWriter, overrideConfig *dc.AutomateConfig, skipPreflight bool, ...) error
- func DeployHA(writer cli.FormatWriter, overrideConfig *dc.AutomateConfig, ...) error
- func Destroy(writer cli.FormatWriter, opts UninstallOpts) error
- func DevA1Backup(w cli.FormatWriter, u *a1upgrade.A1Upgrade) error
- func Disconnect()
- func GetAddress() (string, error)
- func GetAutomateConfig(timeout int64) (*api.GetAutomateConfigResponse, error)
- func GetHostPort() (string, string, error)
- func ListBackups(conTimeout, reqTimeout time.Duration) (*api.ListBackupsResponse, error)
- func PatchAutomateConfig(timeout int64, config *dc.AutomateConfig, writer cli.FormatWriter) error
- func Preflight(writer cli.FormatWriter, overrideCfg *dc.AutomateConfig, cliVersion string, ...) error
- func RestoreBackup(conTimeout, reqTimeout time.Duration, restoreTask *api.BackupRestoreTask) (*api.RestoreBackupResponse, error)
- func SetAutomateConfig(timeout int64, config *dc.AutomateConfig, writer cli.FormatWriter) error
- func SetProxyEnvironment(config *dc.ConfigRequest)
- func ShowBackup(conTimeout, reqTimeout time.Duration, id *api.BackupTask) (*api.ShowBackupResponse, error)
- func StreamBackupStatus(conTimeout, reqTimeout time.Duration, taskID string, writer cli.FormatWriter) (*api.DeployEvent, error)
- func ValidateBackupIntegrity(conTimeout, reqTimeout time.Duration, ids []*api.BackupTask) (*api.ValidateBackupIntegrityResponse, error)
- func WarnIfNotUpToDateAgainstServer(connection ManifestVersionClient, writer WarningWriter, version string)
- type CLIEventWriter
- type ConnOpt
- type DSClient
- type DeploymentRestore
- type DeploymentRestoreOpt
- func WithDeploymentRestoreAirgapInstallBundle(airgapInstallBundlePath string) DeploymentRestoreOpt
- func WithDeploymentRestoreSkipBootstrap(skip bool) DeploymentRestoreOpt
- func WithDeploymentRestoreSkipPreflight(skip bool) DeploymentRestoreOpt
- func WithDeploymentRestoreTask(task *api.BackupRestoreTask) DeploymentRestoreOpt
- func WithDeploymentRestoreWriter(writer cli.FormatWriter) DeploymentRestoreOpt
- type ManifestVersionClient
- type UninstallOpts
- type WarningWriter
Constants ¶
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 )
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
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
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 BackupIntegrityShow ¶
func BackupIntegrityShow(conTimeout, reqTimeout time.Duration) (*api.BackupIntegrityShowResponse, error)
BackupIntegrityShow makes a gRPC request to the deployment-service and returns the backup integrity status
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 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, bootstrapBundlePath string) error
Deploy bootstraps the system and then installs Chef Automate v2
func DeployHA ¶
func DeployHA(writer cli.FormatWriter, overrideConfig *dc.AutomateConfig, manifestProvider manifest.ReleaseManifestProvider, cliVersion string, airgap bool, saas bool) error
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 ¶
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 ¶
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 ValidateBackupIntegrity ¶
func ValidateBackupIntegrity(conTimeout, reqTimeout time.Duration, ids []*api.BackupTask) (*api.ValidateBackupIntegrityResponse, error)
ValidateBackupIntegrity makes a gRPC request to the deployment-service and validates the backups that match the associated backup task IDs. If no backup task IDs are provided all backups will be validated. It returns the updated backup integrity status.
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 ¶
type DSClient struct { api.DeployClientStreamer api.CertificateAuthorityServiceClient }
DSClient multiplexes the various clients that the deployment-service can serve.
func Connection ¶
Connection creates (if necessary) a gRPC connection to the deployment service, saves it, and returns it. TODO: Make this function accept and respect a context with a deadline instead of taking a time.Duration.
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) ResolvedManifest ¶
func (r *DeploymentRestore) ResolvedManifest() (manifest.ReleaseManifest, error)
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 WarningWriter ¶
WarningWriter is an interface that we use to warn about version mismatches