Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sandbox/launcher/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ module github.com/robbycochran/harness-openshell/sandbox/launcher

go 1.22.4

require github.com/robbycochran/harness-openshell v0.0.0

require github.com/BurntSushi/toml v1.6.0 // indirect

replace github.com/robbycochran/harness-openshell => ../../
36 changes: 3 additions & 33 deletions sandbox/launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,9 @@ import (
"strings"
"time"

"github.com/BurntSushi/toml"
"github.com/robbycochran/harness-openshell/internal/profile"
)

type Config struct {
Name string `toml:"name"`
From string `toml:"from"`
Command string `toml:"command"`
Keep *bool `toml:"keep"`
Providers []string `toml:"providers"`
Env map[string]string `toml:"env"`
}

func (c *Config) KeepSandbox() bool {
if c.Keep == nil {
return true
}
return *c.Keep
}

func parseConfig(path string) (*Config, error) {
var cfg Config
if _, err := toml.DecodeFile(path, &cfg); err != nil {
return nil, fmt.Errorf("parsing %s: %w", path, err)
}
if cfg.Name == "" {
cfg.Name = "agent"
}
if cfg.Command == "" {
cfg.Command = "claude --bare"
}
return &cfg, nil
}

func configureGateway(endpoint, mtlsDir, cli string) error {
requiredCerts := []string{"ca.crt", "tls.crt", "tls.key"}
var missing []string
Expand Down Expand Up @@ -146,7 +116,7 @@ func stageFiles(harnessDir string) error {
return nil
}

func createSandbox(cfg *Config, providers []string, cli string) error {
func createSandbox(cfg *profile.Config, providers []string, cli string) error {
fmt.Println("\n=== Creating sandbox ===")
for attempt := 1; attempt <= 5; attempt++ {
args := []string{"sandbox", "create", "--name", cfg.Name, "--no-tty"}
Expand Down Expand Up @@ -243,7 +213,7 @@ func main() {
os.Exit(1)
}

cfg, err := parseConfig(configPath)
cfg, err := profile.ParseFile(configPath)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
Expand Down
10 changes: 6 additions & 4 deletions sandbox/launcher/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os"
"path/filepath"
"testing"

"github.com/robbycochran/harness-openshell/internal/profile"
)

func TestParseConfig_Full(t *testing.T) {
Expand All @@ -21,7 +23,7 @@ ANTHROPIC_BASE_URL = "https://inference.local"
JIRA_URL = "https://example.atlassian.net"
`), 0o644)

cfg, err := parseConfig(path)
cfg, err := profile.ParseFile(path)
if err != nil {
t.Fatalf("parseConfig: %v", err)
}
Expand Down Expand Up @@ -58,7 +60,7 @@ func TestParseConfig_Defaults(t *testing.T) {
from = "quay.io/test/sandbox:latest"
`), 0o644)

cfg, err := parseConfig(path)
cfg, err := profile.ParseFile(path)
if err != nil {
t.Fatalf("parseConfig: %v", err)
}
Expand All @@ -77,7 +79,7 @@ from = "quay.io/test/sandbox:latest"
}

func TestParseConfig_Missing(t *testing.T) {
_, err := parseConfig("/nonexistent/config.toml")
_, err := profile.ParseFile("/nonexistent/config.toml")
if err == nil {
t.Error("expected error for missing file")
}
Expand All @@ -88,7 +90,7 @@ func TestParseConfig_Invalid(t *testing.T) {
path := filepath.Join(dir, "config.toml")
os.WriteFile(path, []byte(`not valid toml {{{{`), 0o644)

_, err := parseConfig(path)
_, err := profile.ParseFile(path)
if err == nil {
t.Error("expected error for invalid TOML")
}
Expand Down
Loading