Documentation
¶
Overview ¶
Package winrm provides a rig protocol implementation for WinRM connections
Index ¶
- type Config
- type Connection
- func (c *Connection) Connect(ctx context.Context) error
- func (c *Connection) Disconnect()
- func (c *Connection) ExecInteractive(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Connection) IPAddress() string
- func (c *Connection) IsConnected() bool
- func (c *Connection) IsWindows() bool
- func (c *Connection) Protocol() string
- func (c *Connection) ProtocolName() 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:"-" json:"-"`
Address string `` /* 130-byte string literal not displayed */
User string `` /* 166-byte string literal not displayed */
Port int `` /* 177-byte string literal not displayed */
Password string `yaml:"password,omitempty" json:"password,omitempty" jsonschema:"minLength=1,description=Password for WinRM authentication"`
UseHTTPS bool `yaml:"useHTTPS" json:"useHTTPS,omitempty" default:"false" jsonschema:"default=false,description=Use HTTPS for WinRM"`
Insecure bool `` /* 128-byte string literal not displayed */
UseNTLM bool `yaml:"useNTLM" json:"useNTLM,omitempty" default:"false" jsonschema:"default=false,description=Use NTLM authentication"`
CACertPath string `` /* 129-byte string literal not displayed */
CertPath string `` /* 141-byte string literal not displayed */
KeyPath string `` /* 131-byte string literal not displayed */
TLSServerName string `` /* 152-byte string literal not displayed */
Bastion *ssh.Config `yaml:"bastion,omitempty" json:"bastion,omitempty" jsonschema:"description=Optional SSH bastion"`
}
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(ctx context.Context) error
Connect opens the WinRM connection. Any existing connection is torn down first.
func (*Connection) Disconnect ¶
func (c *Connection) Disconnect()
Disconnect closes the WinRM connection.
func (*Connection) ExecInteractive ¶
func (c *Connection) ExecInteractive(ctx context.Context, 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. The session is terminated when ctx is cancelled.
func (*Connection) IPAddress ¶
func (c *Connection) IPAddress() string
IPAddress returns the connection address.
func (*Connection) IsConnected ¶
func (c *Connection) IsConnected() bool
IsConnected returns true if the WinRM connection is alive by running a no-op command. WinRM is stateless HTTP so the only real liveness test is a probe.
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 family, "WinRM".
func (*Connection) ProtocolName ¶
func (c *Connection) ProtocolName() string
ProtocolName returns the implementation 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.
If ctx is done first, Wait returns a context error instead of waiting for a command the host may never finish. The remote command is then torn down in the background, so on that path -- and only on that path -- Wait can return while the goroutines copying the command's output are still running. They are cut loose from stdout and stderr before Wait returns, but one write already in progress cannot be interrupted, because an io.Writer offers no way to do so and waiting for it would make Wait unbounded again. The same goes for stdin, which is read through a reader that stops at the next read boundary once ctx is done but cannot abandon a read already under way. A caller that recycles, closes or concurrently uses any of the three streams it passed in must therefore not do so when Wait reports a context error.
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.