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
- func GracefullyTearDownState(o *okctl.Okctl) error
- func LoadClusterDeclarationFromPath(o *okctl.Okctl, path *string) (*v1alpha1.Cluster, error)
- type InitializeEnvironmentOpts
- type RunEer
- func AcquireStateLock(o *okctl.Okctl) RunEer
- func ClearLocalState(o *okctl.Okctl) RunEer
- func DownloadState(o *okctl.Okctl, writable bool) RunEer
- func EmitEndCommandExecutionEvent(action metrics.Action) RunEer
- func EmitStartCommandExecutionEvent(action metrics.Action) RunEer
- func InitializeEnvironment(o *okctl.Okctl) RunEer
- func InitializeEnvironmentWithOpts(o *okctl.Okctl, opts InitializeEnvironmentOpts) RunEer
- func InitializeMetrics(o *okctl.Okctl) RunEer
- func InitializeOkctl(o *okctl.Okctl) RunEer
- func LoadClusterDeclaration(o *okctl.Okctl, declarationPath *string) RunEer
- func LoadUserData(o *okctl.Okctl) RunEer
- func PurgeRemoteState(o *okctl.Okctl) RunEer
- func ReleaseStateLock(o *okctl.Okctl) RunEer
- func RunECombinator(preRunEers ...RunEer) RunEer
- func UploadState(o *okctl.Okctl) RunEer
- func ValidatePostgresApplicationName(o *okctl.Okctl, applicationName *string) RunEer
- func VerifyClusterExistsInState(o *okctl.Okctl) RunEer
- func WriteKubeConfig(o *okctl.Okctl) RunEer
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 ¶
GracefullyTearDownState gracefully tears down the state by uploading current state, releasing the state lock and clearing the local state
func LoadClusterDeclarationFromPath ¶
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 ¶
RunEer defines the function signature the Cobra library expects
func AcquireStateLock ¶
AcquireStateLock prevents state to be mutated by anyone other than the client in possession of the lock
func ClearLocalState ¶
ClearLocalState cleans up the localState directory ensuring no leftover local state
func DownloadState ¶
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 ¶
EmitEndCommandExecutionEvent publishes an event indicating the end of a command
func EmitStartCommandExecutionEvent ¶
EmitStartCommandExecutionEvent publishes an event indicating the start of a command
func InitializeEnvironment ¶
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 ¶
InitializeMetrics initializes required metrics data
func InitializeOkctl ¶
InitializeOkctl initializes the okctl instance
func LoadClusterDeclaration ¶
LoadClusterDeclaration loads a cluster declaration path from disk or stdin and stores it in o.Declaration
func LoadUserData ¶
LoadUserData ensures the o.UserData is loaded or created
func PurgeRemoteState ¶
PurgeRemoteState removes all traces of remote state suitable for a delete environment kind of operation
func ReleaseStateLock ¶
ReleaseStateLock releases the state mutation prevention allowing other clients to mutate state
func RunECombinator ¶
RunECombinator takes an arbitrary amount of preRunE functions and runs them all
func UploadState ¶
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 ¶
ValidatePostgresApplicationName ensures that applicationName matches an existing database
func VerifyClusterExistsInState ¶
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 ¶
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.