transport

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package transport defines a uniform interface for "talk to a remote host" regardless of the underlying mechanism (SSH, jump chain, sdjz-relay, ...).

All concrete transports take a Resolver that maps host names to records and secret references to plaintext, so credentials live in the vault and never leak into transport implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecOptions

type ExecOptions struct {
	Stdin   io.Reader
	Timeout time.Duration
}

ExecOptions customises a single Exec call.

type ExecResult

type ExecResult struct {
	ExitCode int           `json:"exit_code"`
	Stdout   []byte        `json:"stdout"`
	Stderr   []byte        `json:"stderr"`
	Duration time.Duration `json:"duration_ms"`
}

ExecResult is what we report back after running a command.

type Resolver

type Resolver interface {
	GetHost(ctx context.Context, name string) (*inventory.Host, error)
	GetSecret(ctx context.Context, name string) (string, error)
}

Resolver is what a transport uses to fetch the data it needs from the surrounding services (inventory + vault). Decoupling is intentional so that transports can be unit-tested with fakes.

type Transport

type Transport interface {
	// Exec runs a command on the remote, returning its full output.
	Exec(ctx context.Context, cmd string, opts ExecOptions) (*ExecResult, error)

	// Put copies a stream into a remote file.
	Put(ctx context.Context, src io.Reader, dst string, mode os.FileMode) error

	// Get streams a remote file out to the writer.
	Get(ctx context.Context, src string, dst io.Writer) error

	// Close releases any underlying connection.
	Close() error
}

Transport is a connection to one host.

func Open

func Open(ctx context.Context, h *inventory.Host, r Resolver) (Transport, error)

Open dials the host using whatever transport its record specifies. The returned Transport must be Close()d by the caller.

Jump to

Keyboard shortcuts

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