winrm

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package winrm provides a rig protocol implementation for WinRM connections

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	log.LoggerInjectable `yaml:"-"`
	Address              string      `yaml:"address" validate:"required,hostname_rfc1123|ip"`
	User                 string      `yaml:"user" validate:"omitempty,gt=2" default:"Administrator"`
	Port                 int         `yaml:"port" default:"5985" validate:"gt=0,lte=65535"`
	Password             string      `yaml:"password,omitempty"`
	UseHTTPS             bool        `yaml:"useHTTPS" default:"false"`
	Insecure             bool        `yaml:"insecure" default:"false"`
	UseNTLM              bool        `yaml:"useNTLM" default:"false"`
	CACertPath           string      `yaml:"caCertPath,omitempty" validate:"omitempty,file"`
	CertPath             string      `yaml:"certPath,omitempty" validate:"omitempty,file"`
	KeyPath              string      `yaml:"keyPath,omitempty" validate:"omitempty,file"`
	TLSServerName        string      `yaml:"tlsServerName,omitempty" validate:"omitempty,hostname_rfc1123|ip"`
	Bastion              *ssh.Config `yaml:"bastion,omitempty"`
}

Config describes the configuration options for a WinRM connection.

func (*Config) Connection

func (c *Config) Connection() (protocol.Connection, error)

Connection returns a new WinRM Connection based on the configuration.

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets various default values.

func (*Config) String

func (c *Config) String() string

String returns a string representation of the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for any invalid values.

type Connection

type Connection struct {
	log.LoggerInjectable `yaml:"-"`
	Config               `yaml:",inline"`
	// contains filtered or unexported fields
}

Connection describes a Connection connection with its configuration options.

func NewConnection

func NewConnection(cfg Config, opts ...Option) (*Connection, error)

NewConnection creates a new WinRM connection. Error is currently always nil.

func (*Connection) Connect

func (c *Connection) Connect() error

Connect opens the WinRM connection.

func (*Connection) Disconnect

func (c *Connection) Disconnect()

Disconnect closes the WinRM connection.

func (*Connection) ExecInteractive

func (c *Connection) ExecInteractive(cmd string, stdin io.Reader, stdout, stderr io.Writer) error

ExecInteractive executes a command on the host and passes stdin/stdout/stderr as-is to the session.

func (*Connection) IPAddress

func (c *Connection) IPAddress() string

IPAddress returns the connection address.

func (*Connection) IsWindows

func (c *Connection) IsWindows() bool

IsWindows always returns true on winrm.

func (*Connection) Protocol

func (c *Connection) Protocol() string

Protocol returns the protocol name, "WinRM".

func (*Connection) StartProcess

func (c *Connection) StartProcess(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) (protocol.Waiter, error)

StartProcess executes a command on the remote host and uses the passed in streams for stdin, stdout and stderr. It returns a Waiter with a .Wait() function that blocks until the command finishes and returns an error if the exit code is not zero.

func (*Connection) String

func (c *Connection) String() string

String returns the connection's printable name.

type Option

type Option func(*Options)

Option is a functional option for WinRM Options.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger sets the logger for the WinRM client.

type Options

type Options struct {
	log.LoggerInjectable
}

Options for WinRM connetion.

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions creates a new Options struct with the provided options.

Jump to

Keyboard shortcuts

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