client

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package client provides functionality so that other uses of sansshell can provide their own main.go without having to cargo-cult everything across for common use cases. i.e. adding additional modules that are locally defined.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommandLineCompletion added in v1.18.1

func AddCommandLineCompletion(topLevelFlagPredictions map[string]Predictor)

AddCommandLineCompletion adds command line completion for shells. It should be called after registering all subcommands and before calling flag.Parse().

topLevelFlagPredictions gives optional finer-grained control over predictions on the top-level flags.

func Run

func Run(ctx context.Context, rs RunState)

Run takes the given context and RunState and executes the command passed in after parsing with flags. As this is intended to be called from main() it doesn't return errors and will instead exit on any errors.

func StreamClientTimeoutInterceptor added in v1.23.3

func StreamClientTimeoutInterceptor(timeout time.Duration) grpc.StreamClientInterceptor

StreamClientTimeoutInterceptor returns a grpc.UnaryClientInterceptor that adds a deadline to every client SendMsg and RecvMsg

func UnaryClientTimeoutInterceptor added in v1.23.3

func UnaryClientTimeoutInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor

UnaryClientTimeoutInterceptor returns a grpc.UnaryClientInterceptor that adds a deadline to every request

Types

type Predictor added in v1.18.1

type Predictor func(prefix string) []string

Predictor can provide suggested values based on a provided prefix.

type RunState added in v1.0.2

type RunState struct {
	// Proxy is an optional proxy server to route requests.
	Proxy string
	// Targets is a list of remote targets to use when a proxy
	// is in use. For non proxy must be 1 entry.
	Targets []string
	// Outputs must map 1:1 with Targets indicating where to emit
	// output from commands. If the list is empty or a single entry
	// set to - then stdout/stderr will be used for all outputs.
	Outputs []string
	// OutputsDir defines a directory to place outputs instead of
	// specifying then in Outputs. The files will be names 0.output,
	// 1.output and .error respectively for each target.
	OutputsDir string
	// CredSource is a registered credential source with the mtls package.
	CredSource string
	// IdleTimeout is the time duration to wait before closing an idle connection.
	// If no messages are sent/received within this timeframe, connection will be terminated.
	IdleTimeout time.Duration
	// ClientPolicy is an optional OPA policy for determining outbound decisions.
	ClientPolicy string
	// PrefixOutput if true will prefix every line of output with '<index>-<target>: '
	PrefixOutput bool
	// BatchSize if non-zero will do the requested operation to the targets but in
	// N calls to the proxy where N is the target list size divided by BatchSize.
	BatchSize int
	// If true, add an interceptor that performs the multi-party auth flow
	EnableMPA bool
}

RunState encapsulates all of the variable state needed to run a sansssh command.

Jump to

Keyboard shortcuts

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