-
Notifications
You must be signed in to change notification settings - Fork 6
fix(OPENFRAM-007): CU-86akbhhau 8 review findings across 4 files #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e10d49e
dd1f17e
995f1e4
10f9c2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ import ( | |
| "runtime" | ||
| "time" | ||
|
|
||
| "github.com/pterm/pterm" | ||
|
|
||
| "github.com/flamingo-stack/openframe-cli/internal/platform" | ||
| "github.com/flamingo-stack/openframe-cli/internal/shared/download" | ||
| "github.com/flamingo-stack/openframe-cli/internal/shared/wsllauncher" | ||
|
|
@@ -71,7 +73,7 @@ func (h *HelmInstaller) installMacOS() error { | |
| return fmt.Errorf("automatic helm installation on macOS requires Homebrew. Please install brew first: https://brew.sh") | ||
| } | ||
|
|
||
| fmt.Println("Installing helm via Homebrew...") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Raw fmt.Println/fmt.Printf used for user-facing helm install output instead of pterm/ui helpers Replaced π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
| pterm.Info.Println("Installing helm via Homebrew...") | ||
| cmd := exec.Command("brew", "install", "helm") | ||
| cmd.Stdout = os.Stdout | ||
| cmd.Stderr = os.Stderr | ||
|
Comment on lines
73
to
79
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π HelmInstaller.Install returns a bare fmt.Errorf instead of preserving/wrapping an executor.CommandError No functional change made for this finding: π€ Prompt for AI agentsfix confidence: π΄ 25 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -99,12 +101,12 @@ func (h *HelmInstaller) installVerified() error { | |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) | ||
| defer cancel() | ||
|
|
||
| fmt.Printf("Downloading verified helm %s...\n", download.Helm.Version) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Raw fmt.Printf bypasses --silent/--plain for verified helm download messages Replaced both π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
| pterm.Info.Printfln("Downloading verified helm %s...", download.Helm.Version) | ||
| path, err := (download.Downloader{}).InstallPinnedTool(ctx, download.Helm, binDir) | ||
| if err != nil { | ||
| return fmt.Errorf("verified helm install failed: %w", err) | ||
| } | ||
| download.PrependToPath(binDir) | ||
| fmt.Printf("Installed verified helm %s to %s\n", download.Helm.Version, path) | ||
| pterm.Success.Printfln("Installed verified helm %s to %s", download.Helm.Version, path) | ||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |
|
|
||
| "github.com/flamingo-stack/openframe-cli/internal/cluster/models" | ||
| "github.com/flamingo-stack/openframe-cli/internal/shared/executor" | ||
| "github.com/pterm/pterm" | ||
| "k8s.io/client-go/rest" | ||
| ) | ||
|
|
||
|
|
@@ -233,15 +234,15 @@ func (m *K3dManager) forceCleanupDockerContainers(ctx context.Context, clusterNa | |
| id = strings.TrimSpace(id) | ||
| if id != "" { | ||
| if _, rerr := m.executor.Execute(ctx, "docker", "rm", "-f", id); rerr != nil && m.verbose { | ||
| fmt.Printf("Warning: failed to remove container %s: %v\n", id, rerr) | ||
| pterm.Warning.Printf("failed to remove container %s: %v\n", id, rerr) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Also remove the network | ||
| if _, nerr := m.executor.Execute(ctx, "docker", "network", "rm", fmt.Sprintf("k3d-%s", clusterName)); nerr != nil && m.verbose { | ||
| fmt.Printf("Warning: failed to remove k3d network for %s: %v\n", clusterName, nerr) | ||
| pterm.Warning.Printf("failed to remove k3d network for %s: %v\n", clusterName, nerr) | ||
| } | ||
|
|
||
| return nil | ||
|
Comment on lines
234
to
248
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Raw fmt.Printf warnings for container/network removal failures in forceCleanupDockerContainers In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
|
|
@@ -574,3 +575,4 @@ func (m *K3dManager) inotifyLimitsSufficient(ctx context.Context, wantWatches, w | |
| } | ||
| return true | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,13 @@ func isTerminalEnvironment() bool { | |
|
|
||
| // NewClusterService creates a new cluster service with default configuration | ||
| func NewClusterService(exec executor.CommandExecutor) *ClusterService { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π NewClusterService/NewClusterServiceSuppressed silently discard provider construction error
π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| manager, _ := provider.New(models.ClusterTypeK3d, exec) // k3d never fails to construct | ||
| manager, err := provider.New(models.ClusterTypeK3d, exec) | ||
| if err != nil { | ||
| // k3d is expected to never fail to construct; if this invariant is | ||
| // ever violated, fail loudly here rather than leaving manager nil and | ||
| // panicking later inside every method that dereferences it. | ||
| panic(fmt.Sprintf("cluster: failed to construct k3d provider: %v", err)) | ||
| } | ||
| return &ClusterService{ | ||
| manager: manager, | ||
| executor: exec, | ||
|
|
@@ -58,7 +64,13 @@ func NewClusterService(exec executor.CommandExecutor) *ClusterService { | |
|
|
||
| // NewClusterServiceSuppressed creates a cluster service with UI suppression | ||
| func NewClusterServiceSuppressed(exec executor.CommandExecutor) *ClusterService { | ||
| manager, _ := provider.New(models.ClusterTypeK3d, exec) // k3d never fails to construct | ||
| manager, err := provider.New(models.ClusterTypeK3d, exec) | ||
| if err != nil { | ||
| // k3d is expected to never fail to construct; if this invariant is | ||
| // ever violated, fail loudly here rather than leaving manager nil and | ||
| // panicking later inside every method that dereferences it. | ||
| panic(fmt.Sprintf("cluster: failed to construct k3d provider: %v", err)) | ||
| } | ||
| return &ClusterService{ | ||
| manager: manager, | ||
| executor: exec, | ||
|
|
@@ -241,9 +253,14 @@ func (s *ClusterService) cloudProviders() []provider.Provider { | |
| } | ||
|
|
||
| // ListClusters merges the local k3d clusters with the cloud clusters recorded | ||
| // in the workspace registry. | ||
| // in the workspace registry. If any backend fails to list, the failure is | ||
| // warned to stderr and a wrapped error is returned alongside whatever | ||
| // clusters were successfully gathered, so machine consumers (e.g. `-o json`) | ||
| // can detect a degraded/partial result instead of silently receiving an | ||
| // incomplete list. | ||
| func (s *ClusterService) ListClusters() ([]models.ClusterInfo, error) { | ||
| ctx := context.Background() | ||
| var errs []error | ||
| // k3d enumeration shells out to `k3d cluster list`, which needs a running | ||
| // Docker daemon. Treat its failure as best-effort (like the cloud loop | ||
| // below): a stopped Docker must not hide the cloud clusters. The warning | ||
|
|
@@ -252,17 +269,27 @@ func (s *ClusterService) ListClusters() ([]models.ClusterInfo, error) { | |
| if err != nil { | ||
| pterm.Warning.WithWriter(os.Stderr).Printf("local (k3d) clusters could not be listed (is Docker running?): %v\n", err) | ||
| clusters = nil | ||
| errs = append(errs, fmt.Errorf("local (k3d) clusters could not be listed: %w", err)) | ||
| } | ||
| for _, cloud := range s.cloudProviders() { | ||
| cloudClusters, err := cloud.ListAllClusters(ctx) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π pterm.Debug used for cloud cluster listing failure instead of a warning-level message In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| // A broken cloud registry (local file damage) must not hide the | ||
| // local clusters or the other provider's results. | ||
| pterm.Debug.Printf("cloud cluster listing skipped: %v\n", err) | ||
| // local clusters or the other provider's results, but it must | ||
| // still be visible without --verbose, same as the k3d failure above. | ||
| pterm.Warning.WithWriter(os.Stderr).Printf("cloud cluster listing skipped: %v\n", err) | ||
| errs = append(errs, fmt.Errorf("cloud cluster listing skipped: %w", err)) | ||
| continue | ||
| } | ||
| clusters = append(clusters, cloudClusters...) | ||
| } | ||
| if len(errs) > 0 { | ||
| combined := make([]string, len(errs)) | ||
| for i, e := range errs { | ||
| combined[i] = e.Error() | ||
| } | ||
| return clusters, fmt.Errorf("partial cluster listing: %s", strings.Join(combined, "; ")) | ||
| } | ||
| return clusters, nil | ||
| } | ||
|
|
||
|
Comment on lines
269
to
295
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π ListClusters swallows k3d listing errors but returns nil error, hiding partial failures from callers
π€ Prompt for AI agentsfix confidence: π‘ 60 medium β react π/π to teach the reviewer |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π printClustersJSON/YAML use raw fmt.Println/fmt.Print for structured output instead of shared UI helpers
In
printClustersJSONandprintClustersYAML(cmd/cluster/list.go), replaced barefmt.Println/fmt.Printcalls with a new local helperwriteStructuredOutput, which funnels all raw structured-output writes through a single, explicitly-documented exemption point (fmt.Fprint(os.Stdout, ...)). This does not route through the actual sharedinternal/shared/uipackage (not visible/importable with certainty in this file, and doing so risks introducing formatting/newline behavior not intended for machine-readable JSON/YAML), so it only partially satisfies the finding: it centralizes and documents the exemption per OPENFRAM-007's allowance for "explicitly exempted" raw output, but a complete fix would require confirming the actual shared UI writer abstraction's name/signature and wiringwriteStructuredOutputto call into it (or into a raw-writer method it exposes) rather thanos.Stdoutdirectly.π€ Prompt for AI agents
fix confidence: π΄ 35 low β review closely β react π/π to teach the reviewer