Skip to content

Commit 5c490d8

Browse files
authored
refactor: Remove helpers orphaned by KMCP removal (#3562)
# Description Removing the KMCP integration and the `kagent mcp` scaffolder in #3223 left the shared CLI helpers it used without callers. This removes the Docker executor, project generator, filesystem, Kubernetes config, and input prompt helpers, trims the kubectl executor to what `kagent bug-report` still uses, and drops the `logging.FromLogr` adapter whose only caller was the MCPServer catalog check. No behavior change. The remaining `deadcode` findings are public STS helpers and the `WithGRPCTransportCredentials` client option, which are intentionally kept as consumer-facing extension points. Signed-off-by: timflannagan <[email protected]>
1 parent aaf1ca8 commit 5c490d8

7 files changed

Lines changed: 0 additions & 482 deletions

File tree

‎go/core/cli/internal/common/exec/docker.go‎

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package exec
22

33
import (
4-
"bytes"
5-
"context"
64
"fmt"
7-
"io"
8-
"os"
95
"os/exec"
106
"strings"
11-
"time"
127
)
138

149
// KubectlExecutor provides utilities for running kubectl commands with consistent
@@ -29,34 +24,6 @@ func NewKubectlExecutor(verbose bool, namespace string) *KubectlExecutor {
2924
}
3025
}
3126

32-
// CheckAvailability checks if kubectl is installed and accessible.
33-
func (k *KubectlExecutor) CheckAvailability() error {
34-
cmd := exec.Command("kubectl", "version", "--client")
35-
if err := cmd.Run(); err != nil {
36-
return fmt.Errorf("kubectl not found or not working: %w", err)
37-
}
38-
return nil
39-
}
40-
41-
// Run executes a kubectl command with the given arguments.
42-
// It automatically handles verbose logging and captures stderr for better error messages.
43-
func (k *KubectlExecutor) Run(args ...string) error {
44-
if k.Verbose {
45-
fmt.Printf("Running: kubectl %s\n", strings.Join(args, " "))
46-
}
47-
48-
cmd := exec.Command("kubectl", args...)
49-
var stderr bytes.Buffer
50-
cmd.Stdout = os.Stdout
51-
cmd.Stderr = io.MultiWriter(os.Stderr, &stderr)
52-
53-
if err := cmd.Run(); err != nil {
54-
return fmt.Errorf("`kubectl %s` failed: %w\n%s", strings.Join(args, " "), err, stderr.String())
55-
}
56-
57-
return nil
58-
}
59-
6027
// RunWithOutput executes a kubectl command and returns the combined output.
6128
// This is useful for capturing command output for further processing.
6229
func (k *KubectlExecutor) RunWithOutput(args ...string) ([]byte, error) {
@@ -72,88 +39,3 @@ func (k *KubectlExecutor) RunWithOutput(args ...string) ([]byte, error) {
7239

7340
return output, nil
7441
}
75-
76-
// Apply applies YAML resources to the Kubernetes cluster.
77-
// Multiple YAML documents can be provided and will be combined with separators.
78-
func (k *KubectlExecutor) Apply(yamls ...[]byte) error {
79-
fmt.Printf("🚀 Applying resources to cluster...\n")
80-
81-
// Check if kubectl is available
82-
if err := k.CheckAvailability(); err != nil {
83-
return fmt.Errorf("kubectl is required for cluster deployment: %w", err)
84-
}
85-
86-
// Create temporary file for kubectl apply
87-
tmpFile, err := os.CreateTemp("", "resources-*.yaml")
88-
if err != nil {
89-
return fmt.Errorf("failed to create temp file: %w", err)
90-
}
91-
defer func() {
92-
if err := os.Remove(tmpFile.Name()); err != nil {
93-
fmt.Printf("Warning: failed to remove temp file: %v\n", err)
94-
}
95-
}()
96-
97-
// Combine all YAML resources with separators
98-
var combinedYAML []byte
99-
for i, yaml := range yamls {
100-
if i > 0 {
101-
combinedYAML = append(combinedYAML, []byte("\n---\n")...)
102-
}
103-
combinedYAML = append(combinedYAML, yaml...)
104-
}
105-
106-
if _, err := tmpFile.Write(combinedYAML); err != nil {
107-
return fmt.Errorf("failed to write to temp file: %w", err)
108-
}
109-
if err := tmpFile.Close(); err != nil {
110-
return fmt.Errorf("failed to close temp file: %w", err)
111-
}
112-
113-
// Apply using kubectl
114-
if err := k.Run("apply", "-f", tmpFile.Name()); err != nil {
115-
return err
116-
}
117-
118-
fmt.Printf("✅ Resources applied successfully\n")
119-
return nil
120-
}
121-
122-
// WaitForDeployment waits for a Kubernetes deployment to be ready.
123-
// It uses kubectl rollout status to monitor the deployment progress.
124-
func (k *KubectlExecutor) WaitForDeployment(name string, timeout time.Duration) error {
125-
ctx, cancel := context.WithTimeout(context.Background(), timeout)
126-
defer cancel()
127-
128-
namespace := k.Namespace
129-
if namespace == "" {
130-
namespace = "default"
131-
}
132-
133-
args := []string{
134-
"rollout", "status", "deployment", name,
135-
"-n", namespace,
136-
"--timeout", timeout.String(),
137-
}
138-
139-
cmd := exec.CommandContext(ctx, "kubectl", args...)
140-
if k.Verbose {
141-
fmt.Printf("Running: kubectl %s\n", strings.Join(args, " "))
142-
}
143-
144-
var stderr bytes.Buffer
145-
cmd.Stdout = os.Stdout
146-
cmd.Stderr = io.MultiWriter(os.Stderr, &stderr)
147-
148-
// Sleep briefly to allow controller to create the deployment
149-
time.Sleep(1 * time.Second)
150-
151-
if err := cmd.Run(); err != nil {
152-
if ctx.Err() == context.DeadlineExceeded {
153-
return fmt.Errorf("timed out waiting for deployment to be ready")
154-
}
155-
return fmt.Errorf("`kubectl rollout status` failed: %w\n%s", err, stderr.String())
156-
}
157-
158-
return nil
159-
}

‎go/core/cli/internal/common/fs/project.go‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)