Documentation
¶
Overview ¶
Package dockerimg
Index ¶
- func CheckForIncludeWithFS(fs FileSystem, stdinReader bufio.Reader) error
- func CheckSSHReachability(cntrName string) error
- func DefaultImage() (name, dockerfile, tag string)
- func LaunchContainer(ctx context.Context, config ContainerConfig) error
- type ContainerConfig
- type FileSystem
- type KeyGenerator
- type LocalSSHimmer
- type RealFileSystem
- func (fs *RealFileSystem) Mkdir(name string, perm fs.FileMode) error
- func (fs *RealFileSystem) MkdirAll(name string, perm fs.FileMode) error
- func (fs *RealFileSystem) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func (fs *RealFileSystem) ReadFile(name string) ([]byte, error)
- func (fs *RealFileSystem) Rename(oldpath, newpath string) error
- func (fs *RealFileSystem) SafeWriteFile(name string, data []byte, perm fs.FileMode) error
- func (fs *RealFileSystem) Stat(name string) (fs.FileInfo, error)
- func (fs *RealFileSystem) TempFile(dir, pattern string) (*os.File, error)
- func (fs *RealFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error
- type RealKeyGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForIncludeWithFS ¶
func CheckForIncludeWithFS(fs FileSystem, stdinReader bufio.Reader) error
func CheckSSHReachability ¶
CheckSSHReachability checks if the user's SSH config includes the Sketch SSH config file
func DefaultImage ¶
func DefaultImage() (name, dockerfile, tag string)
DefaultImage is intended to ONLY be used by the pushdockerimg.go script.
func LaunchContainer ¶
func LaunchContainer(ctx context.Context, config ContainerConfig) error
LaunchContainer creates a docker container for a project, installs sketch and opens a connection to it. It writes status to stdout.
Types ¶
type ContainerConfig ¶
type ContainerConfig struct {
// SessionID is the unique identifier for this session
SessionID string
// LocalAddr is the initial address to use (though it may be overwritten later)
LocalAddr string
// SkabandAddr is the address of the skaband service if available
SkabandAddr string
// Model is the name of the LLM model to use.
Model string
// ModelURL is the URL of the LLM service.
ModelURL string
// OAIModelName is the openai model name of the LLM model to use.
OAIModelName string
// ModelAPIKey is the API key for LLM service.
ModelAPIKey string
// Path is the local filesystem path to use
Path string
// GitUsername is the username to use for git operations
GitUsername string
// GitEmail is the email to use for git operations
GitEmail string
// OpenBrowser determines whether to open a browser automatically
OpenBrowser bool
// NoCleanup prevents container cleanup when set to true
NoCleanup bool
// ForceRebuild forces rebuilding of the Docker image even if it exists
ForceRebuild bool
// BaseImage is the base Docker image to use for layering the repo
BaseImage string
// Host directory to copy container logs into, if not set to ""
ContainerLogDest string
// Path to pre-built linux sketch binary, or build a new one if set to ""
SketchBinaryLinux string
// Sketch client public key.
SketchPubKey string
// Host port for the container's ssh server
SSHPort int
// Outside information to pass to the container
OutsideHostname string
OutsideOS string
OutsideWorkingDir string
// If true, exit after the first turn
OneShot bool
// Initial prompt
Prompt string
// Verbose enables verbose output
Verbose bool
// DockerArgs are additional arguments to pass to the docker create command
DockerArgs string
// Mounts specifies volumes to mount in the container in format /path/on/host:/path/in/container
Mounts []string
// ExperimentFlag contains the experimental features to enable
ExperimentFlag string
// TermUI enables terminal UI
TermUI bool
// Budget configuration
MaxDollars float64
GitRemoteUrl string
// Original git origin URL from the host repository
OriginalGitOrigin string
// Upstream branch for git work
Upstream string
// Commit hash to checkout from GetRemoteUrl
Commit string
// Outtie's HTTP server
OutsideHTTP string
// Prefix for git branches created by sketch
BranchPrefix string
// LinkToGitHub enables GitHub branch linking in UI
LinkToGitHub bool
// SubtraceToken enables running sketch under subtrace.dev (development only)
SubtraceToken string
// MCPServers contains MCP server configurations
MCPServers []string
// PassthroughUpstream configures upstream remote for passthrough to innie
PassthroughUpstream bool
// DumpLLM requests dumping of raw communications with LLM services to files
DumpLLM bool
// FetchOnLaunch enables git fetch during initialization
FetchOnLaunch bool
}
ContainerConfig holds all configuration for launching a container
type FileSystem ¶
type FileSystem interface {
Stat(name string) (fs.FileInfo, error)
Mkdir(name string, perm fs.FileMode) error
MkdirAll(name string, perm fs.FileMode) error
ReadFile(name string) ([]byte, error)
WriteFile(name string, data []byte, perm fs.FileMode) error
OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
TempFile(dir, pattern string) (*os.File, error)
Rename(oldpath, newpath string) error
SafeWriteFile(name string, data []byte, perm fs.FileMode) error
}
FileSystem represents a filesystem interface for testability
type KeyGenerator ¶
type KeyGenerator interface {
GenerateKeyPair() (ed25519.PrivateKey, ed25519.PublicKey, error)
ConvertToSSHPublicKey(publicKey ed25519.PublicKey) (ssh.PublicKey, error)
}
KeyGenerator represents an interface for generating SSH keys for testability
type LocalSSHimmer ¶
type LocalSSHimmer struct {
// contains filtered or unexported fields
}
LocalSSHimmer does the necessary key pair generation, known_hosts updates, ssh_config file updates etc steps so that ssh can connect to a locally running sketch container to other local processes like vscode without the user having to run the usual ssh obstacle course.
LocalSSHimmer does not modify your default .ssh/config, or known_hosts files. However, in order for you to be able to use it properly you will have to make a one-time edit to your ~/.ssh/config file.
In your ~/.ssh/config file, add the following line:
Include $HOME/.config/sketch/ssh_config
where $HOME is your home directory.
LocalSSHimmer uses Ed25519 keys for improved security and performance.
func NewLocalSSHimmer ¶
func NewLocalSSHimmer(cntrName, sshHost, sshPort string) (*LocalSSHimmer, error)
NewLocalSSHimmer will set up everything so that you can use ssh on localhost to connect to the sketch container. Call #Clean when you are done with the container to remove the various entries it created in its known_hosts and ssh_config files. Also note that this will generate key pairs for both the ssh server identity and the user identity, if these files do not already exist. These key pair files are not deleted by #Cleanup, so they can be re-used across invocations of sketch. This means every sketch container that runs on this host will use the same ssh server identity. The system uses Ed25519 keys for better security and performance.
If this doesn't return an error, you should be able to run "ssh <cntrName>" in a terminal on your host machine to open a shell into the container without having to manually accept changes to your known_hosts file etc.
func (*LocalSSHimmer) Cleanup ¶
func (c *LocalSSHimmer) Cleanup() error
Cleanup removes the container-specific entries from the SSH configuration and known_hosts files. It preserves the certificate authority entries that might be used by other containers.
type RealFileSystem ¶
type RealFileSystem struct{}
RealFileSystem is the default implementation of FileSystem that uses the OS
func (*RealFileSystem) MkdirAll ¶
func (fs *RealFileSystem) MkdirAll(name string, perm fs.FileMode) error
func (*RealFileSystem) Rename ¶
func (fs *RealFileSystem) Rename(oldpath, newpath string) error
func (*RealFileSystem) SafeWriteFile ¶
SafeWriteFile writes data to a temporary file, syncs to disk, creates a backup of the existing file if it exists, and then renames the temporary file to the target file name.
type RealKeyGenerator ¶
type RealKeyGenerator struct{}
RealKeyGenerator is the default implementation of KeyGenerator
func (*RealKeyGenerator) ConvertToSSHPublicKey ¶
func (*RealKeyGenerator) GenerateKeyPair ¶
func (kg *RealKeyGenerator) GenerateKeyPair() (ed25519.PrivateKey, ed25519.PublicKey, error)