Documentation ¶
Overview ¶
Package winrm provides a rig protocol implementation for WinRM connections
Index ¶
- type Config
- type Connection
- func (c *Connection) Connect() error
- func (c *Connection) Disconnect()
- func (c *Connection) ExecInteractive(cmd string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Connection) IPAddress() string
- func (c *Connection) IsWindows() bool
- func (c *Connection) Protocol() string
- func (c *Connection) StartProcess(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) (protocol.Waiter, error)
- func (c *Connection) String() string
- type Option
- type Options
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.
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 ¶
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 ¶
WithLogger sets the logger for the WinRM client.
type Options ¶
type Options struct {
log.LoggerInjectable
}
Options for WinRM connetion.
func NewOptions ¶
NewOptions creates a new Options struct with the provided options.