package hooks

import "github.com/oslokommune/okctl/cmd/okctl/hooks"

Package hooks contains focused initialization functionality used in a command's PreRunE or PostRunE

Index

Variables

var (
	// ErrImmutable indicates no change is possible
	ErrImmutable = errors.New("immutable")
	// ErrNotFound indicates something is missing
	ErrNotFound = errors.New("not found")
	// ErrNotInitialized indicates the state database has yet to be initialized
	ErrNotInitialized = errors.New("not initialized")
)

Functions

func GracefullyTearDownState

func GracefullyTearDownState(o *okctl.Okctl) error

GracefullyTearDownState gracefully tears down the state by uploading current state, releasing the state lock and clearing the local state

func LoadClusterDeclarationFromPath

func LoadClusterDeclarationFromPath(o *okctl.Okctl, path *string) (*v1alpha1.Cluster, error)

LoadClusterDeclarationFromPath loads a cluster declaration path from disk or stdin

Types

type InitializeEnvironmentOpts

type InitializeEnvironmentOpts struct {
	DisableSignalHandling bool
}

InitializeEnvironmentOpts contains opts for initializing an environment

type RunEer

type RunEer func(cmd *cobra.Command, args []string) error

RunEer defines the function signature the Cobra library expects

func AcquireStateLock

func AcquireStateLock(o *okctl.Okctl) RunEer

AcquireStateLock prevents state to be mutated by anyone other than the client in possession of the lock

func ClearLocalState

func ClearLocalState(o *okctl.Okctl) RunEer

ClearLocalState cleans up the localState directory ensuring no leftover local state

func DownloadState

func DownloadState(o *okctl.Okctl, writable bool) RunEer

DownloadState downloads state from remote storage or initializes it Requires the okctl struct to be initialized.

writable: set this to true if you are going to mutate the state

Remember to acquire a lock when state can potentially be mutated

func EmitEndCommandExecutionEvent

func EmitEndCommandExecutionEvent(action metrics.Action) RunEer

EmitEndCommandExecutionEvent publishes an event indicating the end of a command

func EmitStartCommandExecutionEvent

func EmitStartCommandExecutionEvent(action metrics.Action) RunEer

EmitStartCommandExecutionEvent publishes an event indicating the start of a command

func InitializeEnvironment

func InitializeEnvironment(o *okctl.Okctl) RunEer

InitializeEnvironment - initialize everything required for ALL operations

func InitializeEnvironmentWithOpts

func InitializeEnvironmentWithOpts(o *okctl.Okctl, opts InitializeEnvironmentOpts) RunEer

InitializeEnvironmentWithOpts - initialize everything required for ALL operations

func InitializeMetrics

func InitializeMetrics(o *okctl.Okctl) RunEer

InitializeMetrics initializes required metrics data

func InitializeOkctl

func InitializeOkctl(o *okctl.Okctl) RunEer

InitializeOkctl initializes the okctl instance

func LoadClusterDeclaration

func LoadClusterDeclaration(o *okctl.Okctl, declarationPath *string) RunEer

LoadClusterDeclaration loads a cluster declaration path from disk or stdin and stores it in o.Declaration

func LoadUserData

func LoadUserData(o *okctl.Okctl) RunEer

LoadUserData ensures the o.UserData is loaded or created

func PurgeRemoteState

func PurgeRemoteState(o *okctl.Okctl) RunEer

PurgeRemoteState removes all traces of remote state suitable for a delete environment kind of operation

func ReleaseStateLock

func ReleaseStateLock(o *okctl.Okctl) RunEer

ReleaseStateLock releases the state mutation prevention allowing other clients to mutate state

func RunECombinator

func RunECombinator(preRunEers ...RunEer) RunEer

RunECombinator takes an arbitrary amount of preRunE functions and runs them all

func UploadState

func UploadState(o *okctl.Okctl) RunEer

UploadState uploads local state to remote storage Requires the okctl struct to be initialized.

Remember to release the lock after uploading the state.

func ValidatePostgresApplicationName

func ValidatePostgresApplicationName(o *okctl.Okctl, applicationName *string) RunEer

ValidatePostgresApplicationName ensures that applicationName matches an existing database

func VerifyClusterExistsInState

func VerifyClusterExistsInState(o *okctl.Okctl) RunEer

VerifyClusterExistsInState ensures we have a cluster in the state before continuing This could happen if maintenance mode was not run after upgrading to 0.0.80 and we don't have a state.db in S3 - see #491

func WriteKubeConfig

func WriteKubeConfig(o *okctl.Okctl) RunEer

WriteKubeConfig writes the Kubernetes configuration to disk

Source Files

api.go declarations.go doc.go init.go kubeconfig.go metrics.go postgres.go state.go types.go

Version
v0.0.106 (latest)
Published
Oct 21, 2022
Platform
linux/amd64
Imports
25 packages
Last checked
18 hours ago

Tools for package owners.