tools

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ONCTLDIR = ".onctl"
)

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, searchValue string) bool

func CreateDeployOutputFile

func CreateDeployOutputFile(deployOutput *DeployOutput)

func FileToBase64 added in v0.1.2

func FileToBase64(filepath string) string

func Flock added in v0.1.33

func Flock(f *os.File) error

Flock acquires an exclusive advisory lock on f.

func Funlock added in v0.1.33

func Funlock(f *os.File) error

Funlock releases a lock acquired by Flock.

func GenerateMachineUniqueName

func GenerateMachineUniqueName() string

func GenerateUserName added in v0.1.2

func GenerateUserName() string

func GetSubnets

func GetSubnets(svc *ec2.Client, vpcId *string) []types.Subnet

func GetVpcs

func GetVpcs(svc *ec2.Client) *ec2.DescribeVpcsOutput

func NextApplyDir added in v0.1.6

func NextApplyDir(path string) (applyDirName string, nextApplyDirError error)

func ParseDotEnvFile added in v0.1.8

func ParseDotEnvFile(dotEnvFile string) ([]string, error)

func SSHIntoVM

func SSHIntoVM(request SSHIntoVMRequest)

func StringSliceToPointerSlice

func StringSliceToPointerSlice(strSlice []string) []*string

func WhichCloudProvider

func WhichCloudProvider() string

Types

type CopyAndRunRemoteFileConfig added in v0.1.6

type CopyAndRunRemoteFileConfig struct {
	File string
	Vars []string
}

type DeployOutput

type DeployOutput struct {
	Username   string `json:"username"`
	PublicURL  string `json:"public_url"`
	PublicIP   string `json:"public_ip"`
	DockerHost string `json:"docker_host"`
}

type Forward added in v0.1.34

type Forward struct {
	Local      string // host:port to listen on; port 0 picks a free one
	RemoteHost string // usually localhost: the VM itself
	RemotePort int
}

Forward is one port forward: connections to Local on this machine are carried over ssh to RemoteHost:RemotePort as seen from the VM (ssh -L).

func ParseForward added in v0.1.34

func ParseForward(spec, bind string) (Forward, error)

ParseForward parses REMOTE, LOCAL:REMOTE or LOCAL:HOST:REMOTE (ssh -L's form, minus the bind address, which is bind). REMOTE alone listens on the same port number locally.

type Forwarder added in v0.1.34

type Forwarder struct {
	Remote *Remote
	// contains filtered or unexported fields
}

Forwarder carries port forwards over one ssh connection to a VM, reconnecting once if that connection has dropped (a VM paused and resumed, a laptop that slept).

func (*Forwarder) Serve added in v0.1.34

func (f *Forwarder) Serve(ln net.Listener, fw Forward, onErr func(error)) error

Serve accepts on ln and carries each connection to fw's remote end, until ln is closed. Failures are reported per connection through onErr; they don't stop the forward.

type Remote added in v0.1.6

type Remote struct {
	Username    string
	IPAddress   string
	SSHPort     int
	PrivateKey  string
	Passphrase  string
	Spinner     *ui.Spinner
	Client      *ssh.Client
	DialTimeout time.Duration // 0 means default (7s); set to a shorter value for fast-retry polling
	// Dial, when set, opens the connection to the VM's port instead of a
	// TCP dial to IPAddress -- for providers whose VMs have no reachable
	// address (cloud.Dialer).
	Dial func(ctx context.Context, port int) (net.Conn, error)
}

func (*Remote) CopyAndRunRemoteFile added in v0.1.6

func (r *Remote) CopyAndRunRemoteFile(config *CopyAndRunRemoteFileConfig) error

creates a new apply dir and copies the file to the remote ex. ~/.onctl/apply01 executes the file on the remote

func (*Remote) DownloadFile added in v0.1.9

func (r *Remote) DownloadFile(srcPath, dstPath string) error

func (*Remote) NewSSHConnection added in v0.1.6

func (r *Remote) NewSSHConnection() error

func (*Remote) ReadPassphrase added in v0.1.17

func (r *Remote) ReadPassphrase() (string, error)

func (*Remote) RemoteRun added in v0.1.6

func (r *Remote) RemoteRun(remoteRunConfig *RemoteRunConfig) (string, error)

func (*Remote) SCPCopyFileWithProgress added in v0.1.22

func (r *Remote) SCPCopyFileWithProgress(srcPath, dstPath string, progressCallback func(current, total int64)) error

func (*Remote) SSHCopyFileWithProgress added in v0.1.22

func (r *Remote) SSHCopyFileWithProgress(srcPath, dstPath string, progressCallback func(current, total int64)) error

func (*Remote) SSHUploadDir added in v0.1.24

func (r *Remote) SSHUploadDir(srcDir, dstDir string, totalBytes int64, progressCallback func(current, total int64)) error

SSHUploadDir recursively uploads a local directory to a remote path via SFTP. totalBytes should be the pre-calculated total size of the directory for progress reporting.

func (*Remote) WaitForCloudInit added in v0.1.6

func (r *Remote) WaitForCloudInit(timeout string)

WaitForCloudInit waits for cloud-init to finish

func (*Remote) WaitForSSH added in v0.1.24

func (r *Remote) WaitForSSH(timeout string)

WaitForSSH waits until an SSH connection to the remote can be established. It is used by providers (e.g. Firecracker) whose microVMs have no cloud-init readiness signal to wait on.

type RemoteRunConfig added in v0.1.6

type RemoteRunConfig struct {
	Command string
	Vars    []string
}

type SSHIntoVMRequest added in v0.1.14

type SSHIntoVMRequest struct {
	IPAddress      string
	User           string
	Port           int
	PrivateKeyFile string
	Command        []string
	// ProxyCommand, when set, is how ssh reaches the VM (for VMs with no
	// address of their own, like boxes); IPAddress is then just a name.
	ProxyCommand string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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