connector

package
v0.0.0-...-c218ebb Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialSSH

func DialSSH(ctx context.Context, info provider.ConnectInfo, options DialOptions) (*sshClient, error)

func DialWinRM

func DialWinRM(ctx context.Context, info provider.ConnectInfo, opts DialOptions) (*winRMClient, error)

func Run

func Run(ctx context.Context, info provider.ConnectInfo, options ConnectorOptions) error

Types

type Client

type Client interface {
	Run(ctx context.Context, opts RunOptions) error
	Dial(network string, address string) (net.Conn, error)
	DialRun(ctx context.Context, command string) (net.Conn, error)
	Close() error
}

type ConnectorOptions

type ConnectorOptions struct {
	RunOptions
	DialOptions
}

type DialFn

type DialFn func(ctx context.Context, info provider.ConnectInfo, options DialOptions) (Client, error)
var Dial DialFn = func(ctx context.Context, info provider.ConnectInfo, options DialOptions) (Client, error) {
	switch info.Protocol {
	default:
		client, err := DialSSH(ctx, info, options)
		if err != nil {
			return nil, fmt.Errorf("dial ssh: %w", err)
		}
		return client, nil

	case provider.ProtocolWinRM:
		client, err := DialWinRM(ctx, info, options)
		if err != nil {
			return nil, fmt.Errorf("dial winrm: %w", err)
		}
		return client, nil
	}
}

type DialOptions

type DialOptions struct {
	DialFn          func(ctx context.Context, network string, address string) (net.Conn, error)
	UseExternalAddr bool
}

type ExitError

type ExitError struct {
	// contains filtered or unexported fields
}

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) ExitCode

func (e *ExitError) ExitCode() int

func (*ExitError) Is

func (e *ExitError) Is(err error) bool

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type RunOptions

type RunOptions struct {
	Command string
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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