Documentation
¶
Overview ¶
Package transport contains types and interfaces related to transport mechanisms used to connect to managed hosts in Forge.
Index ¶
- Constants
- func DefaultKnownHostsPath() string
- type Escalation
- type MockTransport
- func (m *MockTransport) Arch() (string, error)
- func (m *MockTransport) Close() error
- func (m *MockTransport) Connect() error
- func (m *MockTransport) OS() (string, error)
- func (w *MockTransport) StartPluginSession(ctx context.Context, basePath string, namespace string, pluginName string, ...) (plugin.Session, error)
- func (m *MockTransport) Type() TransportType
- type SSHTransportBuilder
- func (b *SSHTransportBuilder) Build() (Transport, error)
- func (b *SSHTransportBuilder) DontUseKnownHosts() *SSHTransportBuilder
- func (b *SSHTransportBuilder) UseKnownHosts(knownHostsPath string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) UseStrictKnownHosts(knownHostsPath string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithConnectionTimeout(timeout time.Duration) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithHost(host string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithPasswordAuth(password string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithPort(port uint16) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithPublicKeyAuth(privateKey []byte) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithPublicKeyAuthWithPass(privateKey []byte, privateKeyPass string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithTempPath(tempPath string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithUser(user string) *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithoutPasswordAuth() *SSHTransportBuilder
- func (b *SSHTransportBuilder) WithoutPublicKeyAuth() *SSHTransportBuilder
- type Transport
- type TransportType
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func DefaultKnownHostsPath ¶
func DefaultKnownHostsPath() string
Types ¶
type Escalation ¶
type Escalation struct {
// contains filtered or unexported fields
}
Escalation defines the privilege escalation configuration for a transport action.
func NewEscalation ¶
func NewEscalation(password string) *Escalation
NewEscalation creates a new escalation that just escalates privileges, does not impersonate a user, and requires a password.
func NewImpersonation ¶
func NewImpersonation(username, password string) *Escalation
NewImpersonation creates a new escalation that impersonates the given user.
func NewNoPasswordEscalation ¶
func NewNoPasswordEscalation() *Escalation
NewNoPasswordEscalation creates a new escalation that escalates privileges, does not impersonate a user, and does not require a password.
func NewNoPasswordImpersonation ¶
func NewNoPasswordImpersonation(username string) *Escalation
NewNoPasswordImpersonation creates a new escalation that impersonates the given user and does not require a password.
type MockTransport ¶
type MockTransport struct {
TransportType TransportType
}
MockTransport is a mock implementation of the Transport interface for testing purposes.
func NewMockTransport ¶
func NewMockTransport() *MockTransport
NewMockTransport creates a new instance of MockTransport with default settings.
func (*MockTransport) Arch ¶
func (m *MockTransport) Arch() (string, error)
Arch implements Transport.
func (*MockTransport) Connect ¶
func (m *MockTransport) Connect() error
Connect implements Transport.
func (*MockTransport) StartPluginSession ¶
func (w *MockTransport) StartPluginSession( ctx context.Context, basePath string, namespace string, pluginName string, escalation *Escalation, ) (plugin.Session, error)
StartPluginSession implements Transport.
func (*MockTransport) Type ¶
func (m *MockTransport) Type() TransportType
Type implements Transport.
type SSHTransportBuilder ¶
type SSHTransportBuilder struct {
// contains filtered or unexported fields
}
SSHTransportBuilder is a builder for constructing SSH transport instances.
func NewSSHBuilder ¶
func NewSSHBuilder() *SSHTransportBuilder
NewSSHBuilder creates a new SSHTransportBuilder with default settings.
func (*SSHTransportBuilder) Build ¶
func (b *SSHTransportBuilder) Build() (Transport, error)
Build constructs the SSHTransport based on the builder's configuration.
func (*SSHTransportBuilder) DontUseKnownHosts ¶
func (b *SSHTransportBuilder) DontUseKnownHosts() *SSHTransportBuilder
DontUseKnownHosts disables the use of a known hosts file for the SSH transport.
func (*SSHTransportBuilder) UseKnownHosts ¶
func (b *SSHTransportBuilder) UseKnownHosts(knownHostsPath string) *SSHTransportBuilder
UseKnownHosts enables the use of a known hosts file for the SSH transport, adding unknown hosts to the file.
func (*SSHTransportBuilder) UseStrictKnownHosts ¶
func (b *SSHTransportBuilder) UseStrictKnownHosts(knownHostsPath string) *SSHTransportBuilder
UseStrictKnownHosts enables the use of a known hosts file for the SSH transport, enforcing strict host key checking.
func (*SSHTransportBuilder) WithConnectionTimeout ¶
func (b *SSHTransportBuilder) WithConnectionTimeout(timeout time.Duration) *SSHTransportBuilder
WithConnectionTimeout sets the connection timeout for the SSH transport.
func (*SSHTransportBuilder) WithHost ¶
func (b *SSHTransportBuilder) WithHost(host string) *SSHTransportBuilder
WithHost sets the host for the SSH transport.
func (*SSHTransportBuilder) WithPasswordAuth ¶
func (b *SSHTransportBuilder) WithPasswordAuth(password string) *SSHTransportBuilder
WithPasswordAuth disables password authentication for the SSH transport.
func (*SSHTransportBuilder) WithPort ¶
func (b *SSHTransportBuilder) WithPort(port uint16) *SSHTransportBuilder
WithPort sets the port for the SSH transport.
func (*SSHTransportBuilder) WithPublicKeyAuth ¶
func (b *SSHTransportBuilder) WithPublicKeyAuth(privateKey []byte) *SSHTransportBuilder
WithPublicKeyAuth enables public key authentication for the SSH transport.
func (*SSHTransportBuilder) WithPublicKeyAuthWithPass ¶
func (b *SSHTransportBuilder) WithPublicKeyAuthWithPass(privateKey []byte, privateKeyPass string) *SSHTransportBuilder
WithPublicKeyAuthWithPass enables public key authentication with a passphrase for the SSH transport.
func (*SSHTransportBuilder) WithTempPath ¶
func (b *SSHTransportBuilder) WithTempPath(tempPath string) *SSHTransportBuilder
WithTempPath sets the temporary path for the SSH transport.
func (*SSHTransportBuilder) WithUser ¶
func (b *SSHTransportBuilder) WithUser(user string) *SSHTransportBuilder
WithUser sets the user for the SSH transport.
func (*SSHTransportBuilder) WithoutPasswordAuth ¶
func (b *SSHTransportBuilder) WithoutPasswordAuth() *SSHTransportBuilder
WithoutPasswordAuth disables password authentication for the SSH transport.
func (*SSHTransportBuilder) WithoutPublicKeyAuth ¶
func (b *SSHTransportBuilder) WithoutPublicKeyAuth() *SSHTransportBuilder
WithoutPublicKeyAuth disables public key authentication for the SSH transport.
type Transport ¶
type Transport interface {
Type() TransportType // Type returns the type of transport. This is used for testing only.
OS() (string, error) // OS returns the operating system of the managed system.
Arch() (string, error) // Arch returns the architecture of the managed system.
Connect() error // Connect establishes the transport connection.
Close() error // Close terminates the transport connection.
// StartPluginSession initializes a plugin session.
//
// basePath specifies the base path for plugins.
//
// namespace specifies the namespace of the plugin in the filename.
//
// pluginName specifies the name of the plugin in the filename.
// The OS, architecture, and extension, if applicable, will be appended to this path.
//
// escalation specifies the escalation method to use when starting the plugin session, if any.
// This is nil if no escalation is needed.
//
// It returns a plugin.Session that represents the running plugin process and provides access to its standard input,
// output, and error streams.
StartPluginSession(
ctx context.Context,
basePath string,
namespace string,
pluginName string,
escalation *Escalation,
) (plugin.Session, error)
}
Transport defines the transport mechanism for interacting a managed system.
var (
LocalTransport Transport = &localTransport{}
)
type TransportType ¶
type TransportType string
TransportType represents the type of transport used for connecting to managed systems.
const ( TransportTypeLocal TransportType = "local" TransportTypeSSH TransportType = "ssh" )