Skip to content

Commit 386452d

Browse files
committed
fix: clean up output formatting and fix standalone providers bug
Quiet noisy kubectl/helm passthrough output in deploy (CRD install, SCC grants, rollout status now captured instead of streamed). Switch phase headers from === Section === to Header() with underline. Fix registerProviders printing "Done. Launch a sandbox with: harness up --local" when called from up --remote by adding a standalone parameter. Add top-level context lines (agent name, image) at the start of up flows. Remove inconsistent spacing and stray fmt.Println() calls.
1 parent 6c7108f commit 386452d

5 files changed

Lines changed: 112 additions & 139 deletions

File tree

‎cmd/create.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewCreateCmd(harnessDir, cli string) *cobra.Command {
4242
}
4343
isLocal := strings.Contains(activeGW.Endpoint, "127.0.0.1")
4444

45-
status.Section("Gateway")
45+
status.Header("Gateway")
4646
status.OKf("%s (%s)", activeGW.Name, activeGW.Endpoint)
4747
agentCfg, err := agent.ParseFile(agentPath)
4848
if err != nil {
@@ -60,12 +60,12 @@ func NewCreateCmd(harnessDir, cli string) *cobra.Command {
6060
sandboxImage = envImage
6161
}
6262

63-
status.Section("Agent")
64-
fmt.Printf(" Name: %s\n", name)
65-
fmt.Printf(" Image: %s\n", sandboxImage)
63+
status.Header("Agent")
64+
status.Infof("Name: %s", name)
65+
status.Infof("Image: %s", sandboxImage)
6666

6767
// 3. Validate providers are registered
68-
status.Section("Providers")
68+
status.Header("Providers")
6969
providerNames := agentCfg.ProviderNames()
7070
registered, missing := profile.ValidateProviders(providerNames, gw)
7171
for _, n := range registered {
@@ -84,7 +84,7 @@ func NewCreateCmd(harnessDir, cli string) *cobra.Command {
8484

8585
// 5. Run preflight checks (only for unregistered providers)
8686
if len(missing) > 0 && allProviders != nil {
87-
status.Section("Preflight")
87+
status.Header("Preflight")
8888
preflightOK := true
8989
for _, p := range allProviders {
9090
if !providerInList(p.Name, missing) {
@@ -115,7 +115,7 @@ func NewCreateCmd(harnessDir, cli string) *cobra.Command {
115115
}
116116

117117
// 6. Deploy the sandbox
118-
status.Section("Creating sandbox")
118+
status.Header("Creating sandbox")
119119
if needsRunner {
120120
status.Info("Custom providers detected — using in-cluster runner")
121121
gwCfg := loadGatewayConfigForActive(harnessDir, activeGW)

‎cmd/deploy.go‎

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,13 @@ func deployLocal(gw gateway.Gateway) error {
8080
return fmt.Errorf("openshell CLI not found. Install it first:\n curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh | sh")
8181
}
8282

83-
status.Section("Container Runtime")
83+
status.Header("Deploy")
8484
if _, err := exec.LookPath("podman"); err != nil {
8585
status.Fail("Podman not found")
8686
return fmt.Errorf("podman is required")
8787
}
8888
out, _ := exec.Command("podman", "--version").Output()
8989
status.OKf("Podman: %s", strings.TrimSpace(string(out)))
90-
91-
status.Section("Gateway")
9290
gateways, err := gw.GatewayList()
9391
if err != nil {
9492
return fmt.Errorf("listing gateways: %w", err)
@@ -104,9 +102,8 @@ func deployLocal(gw gateway.Gateway) error {
104102

105103
if localGW == "" {
106104
status.Fail("No local gateway found")
107-
fmt.Println()
108-
fmt.Println(" Install OpenShell (auto-registers the gateway):")
109-
fmt.Println(" curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh | sh")
105+
status.Detail("Install OpenShell (auto-registers the gateway):")
106+
status.Sub("curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh | sh")
110107
return fmt.Errorf("no local gateway")
111108
}
112109

@@ -118,15 +115,11 @@ func deployLocal(gw gateway.Gateway) error {
118115
status.OKf("%s (active, reachable)", localGW)
119116
} else {
120117
status.Failf("%s (not responding)", localGW)
121-
fmt.Println()
122-
fmt.Println(" Start the gateway:")
123-
fmt.Println(" macOS: brew services start openshell")
124-
fmt.Println(" Linux: systemctl --user start openshell")
118+
status.Detail("Start the gateway:")
119+
status.Sub("macOS: brew services start openshell")
120+
status.Sub("Linux: systemctl --user start openshell")
125121
return fmt.Errorf("gateway not responding")
126122
}
127-
128-
fmt.Println()
129-
status.Done("Done.")
130123
return nil
131124
}
132125

@@ -150,14 +143,14 @@ func deployFromConfig(harnessDir string, gwCfg *gateway.GatewayConfig, gw gatewa
150143
chartVersion = gwCfg.Chart.Version
151144
}
152145

153-
fmt.Printf("OpenShell chart: %s\n", chartVersion)
146+
status.Header("Deploy")
147+
status.Infof("Chart: %s", chartVersion)
154148
if kbcfg := os.Getenv("KUBECONFIG"); kbcfg != "" {
155-
fmt.Printf("KUBECONFIG: %s\n", kbcfg)
149+
status.Infof("KUBECONFIG: %s", kbcfg)
156150
}
157-
fmt.Println()
158151

159152
// Step 1: Namespace
160-
status.Step(1, "Creating namespace")
153+
status.Step(1, "Namespace")
161154
clusterRunner.RunKubectl(ctx, "create", "ns", namespace)
162155
if _, err := clusterRunner.RunKubectl(ctx, "label", "ns", namespace,
163156
"pod-security.kubernetes.io/enforce=privileged",
@@ -167,33 +160,33 @@ func deployFromConfig(harnessDir string, gwCfg *gateway.GatewayConfig, gw gatewa
167160
}
168161

169162
// Step 2: Sandbox CRD
170-
status.Step(2, "Installing Sandbox CRD")
171-
if err := clusterRunner.RunKubectlPassthrough(ctx, "apply", "-f", gwCfg.Chart.CRD.URL); err != nil {
163+
status.Step(2, "Sandbox CRD")
164+
if _, err := clusterRunner.RunKubectl(ctx, "apply", "-f", gwCfg.Chart.CRD.URL); err != nil {
172165
return fmt.Errorf("installing sandbox CRD: %w", err)
173166
}
167+
status.OK("Installed")
174168

175169
// Step 3: Platform-specific setup
176170
if gwCfg.IsOCP() {
177-
status.Step(3, "Granting OpenShift SCCs")
171+
status.Step(3, "OpenShift SCCs")
178172
for _, sa := range gwCfg.OCP.SCCPrivileged {
179173
kc.RunOC(ctx, "adm", "policy", "add-scc-to-user", "privileged", "-z", sa, "-n", namespace)
180174
}
181175
for _, sa := range gwCfg.OCP.SCCAnyuid {
182176
kc.RunOC(ctx, "adm", "policy", "add-scc-to-user", "anyuid", "-z", sa, "-n", namespace)
183177
}
184-
// The sandbox controller ClusterRole and ClusterRoleBinding are
185-
// included in the upstream manifest.yaml applied in step 2.
178+
status.OK("Granted")
186179
}
187180

188181
// Addon manifests (RBAC, etc.)
189182
for _, manifestPath := range gwCfg.ManifestPaths() {
190-
if err := kc.RunKubectlPassthrough(ctx, "apply", "-f", manifestPath); err != nil {
183+
if _, err := kc.RunKubectl(ctx, "apply", "-f", manifestPath); err != nil {
191184
return fmt.Errorf("applying %s: %w", filepath.Base(manifestPath), err)
192185
}
193186
}
194187

195188
// Step 4: Helm install
196-
status.Step(4, "Deploying gateway via Helm")
189+
status.Step(4, "Helm install")
197190

198191
// routeHost is needed before Helm (for OCP PKI cert SAN).
199192
// gatewayURL is resolved after Helm for nodeport (service doesn't exist yet).
@@ -229,14 +222,13 @@ func deployFromConfig(harnessDir string, gwCfg *gateway.GatewayConfig, gw gatewa
229222
return fmt.Errorf("helm install failed: %w", err)
230223
}
231224

232-
status.Section("Waiting for gateway")
233-
if err := kc.RunKubectlPassthrough(ctx, "rollout", "status", "statefulset/openshell", "--timeout=300s"); err != nil {
225+
if _, err := kc.RunKubectl(ctx, "rollout", "status", "statefulset/openshell", "--timeout=300s"); err != nil {
234226
return fmt.Errorf("gateway rollout failed: %w", err)
235227
}
228+
status.OK("Gateway ready")
236229

237230
// Step 5: CLI gateway config
238-
// Resolve the gateway URL now that the service exists.
239-
status.Step(5, "Configuring CLI gateway")
231+
status.Step(5, "CLI gateway")
240232
gatewayName := gwCfg.Gateway.Name
241233

242234
var gatewayURL string
@@ -305,23 +297,17 @@ func deployFromConfig(harnessDir string, gwCfg *gateway.GatewayConfig, gw gatewa
305297
status.OKf("%s registered", gatewayName)
306298
}
307299

308-
fmt.Print(" Waiting for gateway...")
309300
var gwReachable bool
310301
for range 30 {
311302
if gw.InferenceGet() == nil {
312303
gwReachable = true
313-
status.OK("reachable")
314304
break
315305
}
316306
time.Sleep(2 * time.Second)
317-
fmt.Print(".")
318307
}
319308
if !gwReachable {
320-
fmt.Println()
321309
return fmt.Errorf("gateway not reachable after 60s (try: openshell inference get)")
322310
}
323-
324-
fmt.Println()
325-
status.Done("Done.")
311+
status.OK("Reachable")
326312
return nil
327313
}

‎cmd/providers.go‎

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func NewProvidersCmd(harnessDir, cli string) *cobra.Command {
2222
Short: "Register providers with the gateway",
2323
RunE: func(cmd *cobra.Command, args []string) error {
2424
gw := gateway.New(cli)
25-
return registerProviders(harnessDir, gw, force, nil)
25+
return registerProviders(harnessDir, gw, force, nil, true)
2626
},
2727
}
2828

@@ -34,7 +34,7 @@ func NewProvidersCmd(harnessDir, cli string) *cobra.Command {
3434
// registerProviders registers providers with the gateway. If gwCfg is non-nil
3535
// and has a [providers] section, only providers in that list are registered.
3636
// Otherwise all providers are registered (backward-compatible behavior).
37-
func registerProviders(harnessDir string, gw gateway.Gateway, force bool, gwCfg *gateway.GatewayConfig) error {
37+
func registerProviders(harnessDir string, gw gateway.Gateway, force bool, gwCfg *gateway.GatewayConfig, standalone bool) error {
3838
model := envOr("OPENSHELL_MODEL", "claude-sonnet-4-6")
3939

4040
// Build the set of enabled provider names from gateway config (if available)
@@ -71,21 +71,16 @@ func registerProviders(harnessDir string, gw gateway.Gateway, force bool, gwCfg
7171
status.Info("Deleted existing providers")
7272
}
7373

74+
status.Header("Providers")
75+
7476
// Enable providers v2
75-
status.Section("Enabling providers v2")
7677
if err := gw.SettingsSet("providers_v2_enabled", "true"); err != nil {
7778
return fmt.Errorf("enabling providers v2: %w", err)
7879
}
7980

8081
// Import custom profiles
81-
status.Section("Importing custom profiles")
8282
profilesDir := filepath.Join(harnessDir, "agents", "providers", "profiles")
83-
if err := gw.ProviderProfileImport(profilesDir); err != nil {
84-
status.Info("already imported")
85-
}
86-
87-
// Register providers
88-
status.Section("Registering providers")
83+
gw.ProviderProfileImport(profilesDir)
8984

9085
if err := registerGitHub(gw, providerEnabled); err != nil {
9186
return err
@@ -100,24 +95,21 @@ func registerProviders(harnessDir string, gw gateway.Gateway, force bool, gwCfg
10095
return err
10196
}
10297

103-
// Show results
104-
status.Section("Providers")
105-
names, err := gw.ProviderList()
106-
if err != nil {
107-
return fmt.Errorf("listing providers: %w", err)
108-
}
109-
for _, n := range names {
110-
status.OK(n)
111-
}
112-
113-
status.Section("Inference")
114-
m := gw.InferenceModel()
115-
if m != "" {
116-
status.OKf("Model: %s", m)
98+
if standalone {
99+
names, err := gw.ProviderList()
100+
if err != nil {
101+
return fmt.Errorf("listing providers: %w", err)
102+
}
103+
fmt.Println()
104+
for _, n := range names {
105+
status.OK(n)
106+
}
107+
m := gw.InferenceModel()
108+
if m != "" {
109+
status.OKf("Inference: %s", m)
110+
}
111+
status.Done("Done. Launch a sandbox with: harness up --local")
117112
}
118-
119-
fmt.Println()
120-
status.Done("Done. Launch a sandbox with: harness up --local")
121113
return nil
122114
}
123115

‎cmd/providers_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestRegisterProviders_GitHubWhenTokenSet(t *testing.T) {
2626
providers: map[string]bool{},
2727
}
2828

29-
err := registerProviders(dir, gw, false, nil)
29+
err := registerProviders(dir, gw, false, nil, true)
3030
if err != nil {
3131
t.Fatalf("registerProviders: %v", err)
3232
}
@@ -41,7 +41,7 @@ func TestRegisterProviders_SkipsWhenTokenMissing(t *testing.T) {
4141
providers: map[string]bool{},
4242
}
4343

44-
err := registerProviders(dir, gw, false, nil)
44+
err := registerProviders(dir, gw, false, nil, true)
4545
if err != nil {
4646
t.Fatalf("registerProviders: %v", err)
4747
}
@@ -56,7 +56,7 @@ func TestRegisterProviders_SkipsExistingProvider(t *testing.T) {
5656
providers: map[string]bool{"github": true},
5757
}
5858

59-
err := registerProviders(dir, gw, false, nil)
59+
err := registerProviders(dir, gw, false, nil, true)
6060
if err != nil {
6161
t.Fatalf("registerProviders: %v", err)
6262
}
@@ -72,7 +72,7 @@ func TestRegisterProviders_ForceWithRunningSandboxes(t *testing.T) {
7272
sandboxes: []string{"test-sandbox"},
7373
}
7474

75-
err := registerProviders(dir, gw, true, nil)
75+
err := registerProviders(dir, gw, true, nil, true)
7676
if err == nil {
7777
t.Fatal("expected error with --force and running sandboxes")
7878
}
@@ -90,7 +90,7 @@ func TestRegisterProviders_ForceDeletesAndRecreates(t *testing.T) {
9090
providers: map[string]bool{},
9191
}
9292

93-
err := registerProviders(dir, gw, true, nil)
93+
err := registerProviders(dir, gw, true, nil, true)
9494
if err != nil {
9595
t.Fatalf("registerProviders: %v", err)
9696
}
@@ -108,7 +108,7 @@ func TestRegisterProviders_RespectsGatewayConfig(t *testing.T) {
108108
gwCfg := &gateway.GatewayConfig{}
109109
gwCfg.Providers.Enabled = []string{"github"}
110110

111-
err := registerProviders(dir, gw, false, gwCfg)
111+
err := registerProviders(dir, gw, false, gwCfg, true)
112112
if err != nil {
113113
t.Fatalf("registerProviders: %v", err)
114114
}
@@ -122,7 +122,7 @@ func TestRegisterProviders_ListError(t *testing.T) {
122122
providerErr: fmt.Errorf("gateway unreachable"),
123123
}
124124

125-
err := registerProviders(dir, gw, false, nil)
125+
err := registerProviders(dir, gw, false, nil, true)
126126
if err == nil {
127127
t.Fatal("expected error when provider list fails")
128128
}

0 commit comments

Comments
 (0)