Documentation
¶
Index ¶
- type Bundler
- type BundlerOption
- type BundlerOptions
- type Check
- type Command
- type File
- type Interface
- type KubeClient
- type KubeProvider
- type KubeProxy
- type KubeProxyCommand
- type ReverseTunnel
- type ReverseTunnelChecker
- type ReverseTunnelKiller
- type SSHClient
- type SSHLoopHandler
- type SSHProvider
- type Script
- type StandaloneClientOpt
- type StandaloneClientOpts
- type Tunnel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BundlerOption ¶
type BundlerOption func(*BundlerOptions)
func BundlerWithNoLogStepOutOnError ¶
func BundlerWithNoLogStepOutOnError(v bool) BundlerOption
func BundlerWithRetries ¶
func BundlerWithRetries(retries int) BundlerOption
func BundlerWithStepDelimiter ¶
func BundlerWithStepDelimiter(delimiter string) BundlerOption
func BundlerWithStepHeaderRegex ¶
func BundlerWithStepHeaderRegex(regex *regexp.Regexp) BundlerOption
type BundlerOptions ¶
type BundlerOptions struct {
StepHeaderRegex *regexp.Regexp
NoLogStepOutOnError bool
StepsDelimiter string
Retries int
}
func (*BundlerOptions) IsValid ¶
func (o *BundlerOptions) IsValid() error
type Command ¶
type Command interface {
Run(ctx context.Context) error
Cmd(ctx context.Context)
Sudo(ctx context.Context)
StdoutBytes() []byte
StderrBytes() []byte
Output(context.Context) ([]byte, []byte, error)
CombinedOutput(context.Context) ([]byte, error)
OnCommandStart(fn func())
WithEnv(env map[string]string)
WithTimeout(timeout time.Duration)
WithStdoutHandler(h func(line string))
WithStderrHandler(h func(line string))
WithSSHArgs(args ...string)
}
type KubeClient ¶
type KubeClient interface {
kubernetes.Interface
Dynamic() dynamic.Interface
APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
APIResource(apiVersion, kind string) (*metav1.APIResource, error)
GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
InvalidateDiscoveryCache()
}
type KubeProvider ¶
type KubeProvider interface {
// Client
// create new client and initialize it
// if it uses over ssh will use current ssh client
// Created client will cache
// if it uses client over ssh can create new client
// if ssh client was switched
// current client will stop if new client was created but not fully
// because if we use over ssh current client can used in another routines
Client(ctx context.Context) (KubeClient, error)
// NewAdditionalClient
// create new additional client and initialize it
// if use over ssh create new ssh client for it
// you should call kube.Stop if client does not need. kube.Stop
// save for all clients not only over ssh
// also provider save all these clients for stop in Cleanup
NewAdditionalClient(ctx context.Context) (KubeClient, error)
// NewAdditionalClientWithoutInitialize
// create new additional client without initialize
// if use over ssh create new ssh client for it
// you should call kube.Stop if client does not need. kube.Stop
// save for all clients not only over ssh
// also provider save all these clients for stop in Cleanup
NewAdditionalClientWithoutInitialize(ctx context.Context) (KubeClient, error)
// Cleanup
// Stops all additional clients got from NewAdditionalClient and NewAdditionalClientWithoutInitialize
// also current client also stop, but not fully
// because if we use over ssh current client can used in another routines
Cleanup(ctx context.Context) error
}
type KubeProxyCommand ¶
type ReverseTunnel ¶
type ReverseTunnel interface {
Up() error
StartHealthMonitor(ctx context.Context, checker ReverseTunnelChecker, killer ReverseTunnelKiller)
Stop()
String() string
}
type ReverseTunnelChecker ¶
type ReverseTunnelKiller ¶
type SSHClient ¶
type SSHClient interface {
// BeforeStart safe starting without create session. Should safe for next Start call
OnlyPreparePrivateKeys() error
Start() error
// Tunnel is used to open local (L) and remote (R) tunnels
Tunnel(address string) Tunnel
// ReverseTunnel is used to open remote (R) tunnel
ReverseTunnel(address string) ReverseTunnel
// Command is used to run commands on remote server
Command(name string, arg ...string) Command
// KubeProxy is used to start kubectl proxy and create a tunnel from local port to proxy port
KubeProxy() KubeProxy
// File is used to upload and download files and directories
File() File
// UploadScript is used to upload script and execute it on remote server
UploadScript(scriptPath string, args ...string) Script
// UploadScript is used to upload script and execute it on remote server
Check() Check
// Stop the client
Stop()
// Loop Looping all available hosts
Loop(fn SSHLoopHandler) error
Session() *session.Session
PrivateKeys() []session.AgentPrivateKey
RefreshPrivateKeys() error
IsStopped() bool
}
type SSHLoopHandler ¶
type SSHProvider ¶
type SSHProvider interface {
// Client
// get current client or initialize from defaults
// after SwitchClient and SwitchToDefault Client will return client initialized
// in SwitchClient and SwitchToDefault method
// SSHProvider can start client after creation if has option for it
Client(ctx context.Context) (SSHClient, error)
// NewAdditionalClient
// initialize new client from default configuration
// use this method if you need more clients not only current
// this method create client from current client setting or from default configuration
// for example if you call SwitchClient next calls of NewAdditionalClient
// create clients for session and private keys passed from SwitchClient
// implementations can store all created clients with NewAdditionalClient
// for stopping in Cleanup
// SSHProvider can start client after creation if has option for it
NewAdditionalClient(ctx context.Context) (SSHClient, error)
// NewStandaloneClient
// initialize new client with passed session settings
// this method create client from passed session
// private keys from default config also passes to new client with privateKeys
// implementations can store all created clients with NewAdditionalClient
// for stopping in Cleanup
// SSHProvider can start client after creation if has option for it
NewStandaloneClient(ctx context.Context, sess *session.Session, privateKeys []session.AgentPrivateKey, opts ...StandaloneClientOpt) (SSHClient, error)
// SwitchClient
// switch current client with new client with provided settings
// method will stop current client but not stop clients created with NewAdditionalClient
// SSHProvider can start client after creation if has option for it
SwitchClient(ctx context.Context, sess *session.Session, privateKeys []session.AgentPrivateKey) (SSHClient, error)
// SwitchToDefault
// switch current client to client with default settings
// method will stop current client but not stop clients created with NewAdditionalClient
// SSHProvider can start client after creation if has option for it
SwitchToDefault(ctx context.Context) (SSHClient, error)
// Cleanup
// stop current client and all clients created with NewAdditionalClient
// and remove all temporary files like private keys with content got from ConnectionConfig
// Cleanup safe for call if no any clients consumed from provider
Cleanup(ctx context.Context) error
}
type Script ¶
type Script interface {
Execute(context.Context) (stdout []byte, err error)
// ExecuteBundle
// run script that start another list of scripts and
// log process of running
// by default running bashible bundle BundlerOption
// if need you can set your own BundlerOption with WithBundlerOpts
// to run your bundle script
ExecuteBundle(ctx context.Context, parentDir, bundleDir string) (stdout []byte, err error)
Sudo()
WithStdoutHandler(handler func(string))
WithTimeout(timeout time.Duration)
WithEnvs(envs map[string]string)
WithCleanupAfterExec(doCleanup bool)
WithNoLogStepOutOnError(enabled bool)
WithExecuteUploadDir(dir string)
WithBundlerOpts(opts ...BundlerOption)
}
type StandaloneClientOpt ¶
type StandaloneClientOpt func(*StandaloneClientOpts)
func SSHClientWithSetFromDefaultsIfNeeded ¶
func SSHClientWithSetFromDefaultsIfNeeded() StandaloneClientOpt
type StandaloneClientOpts ¶
type StandaloneClientOpts struct {
SetSettingsFromDefaultsIfNeeded bool
}
Click to show internal directories.
Click to hide internal directories.