pkg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundler

type Bundler interface {
	Execute(ctx context.Context, parentDir, bundleDir string) ([]byte, error)
}

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 Check

type Check interface {
	WithDelaySeconds(seconds int) Check

	AwaitAvailability(context.Context, retry.Params) error

	CheckAvailability(context.Context) error

	ExpectAvailable(context.Context) ([]byte, error)

	String() string
}

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 File

type File interface {
	Upload(ctx context.Context, srcPath, dstPath string) error
	Download(ctx context.Context, srcPath, dstPath string) error

	UploadBytes(ctx context.Context, data []byte, remotePath string) error
	DownloadBytes(ctx context.Context, remotePath string) ([]byte, error)
}

type Interface

type Interface interface {
	Command(name string, args ...string) Command
	File() File
	UploadScript(scriptPath string, args ...string) Script
}

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 KubeProxy

type KubeProxy interface {
	Start(useLocalPort int) (port string, err error)

	StopAll()

	Stop(startID int)
}

type KubeProxyCommand

type KubeProxyCommand interface {
	Command
	WaitError() error
	Stop()
}

type ReverseTunnel

type ReverseTunnel interface {
	Up() error

	StartHealthMonitor(ctx context.Context, checker ReverseTunnelChecker, killer ReverseTunnelKiller)

	Stop()

	String() string
}

type ReverseTunnelChecker

type ReverseTunnelChecker interface {
	CheckTunnel(context.Context) (string, error)
}

type ReverseTunnelKiller

type ReverseTunnelKiller interface {
	KillTunnel(context.Context) (string, error)
}

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 SSHLoopHandler func(s SSHClient) error

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
}

type Tunnel

type Tunnel interface {
	Up(ctx context.Context) error

	HealthMonitor(errorOutCh chan<- error)

	Stop()

	String() string
}

Jump to

Keyboard shortcuts

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