Repository navigation
fix(FLEETMDM-002-2): CU-86aknprf9 11 review findings across 8 files #413
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
56a19ca
25a7b09
22aa207
baee5dd
94b8e77
4fe0bb3
558000e
80b7531
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |
| "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" | ||
| "github.com/pterm/pterm" | ||
| ) | ||
|
|
||
| type HelmInstaller struct{} | ||
|
|
@@ -89,18 +90,18 @@ func (h *HelmInstaller) installLinux() error { | |
| func (h *HelmInstaller) installVerified() error { | ||
| binDir, err := download.UserBinDir() | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("resolving user bin dir: %w", err) | ||
| } | ||
|
|
||
| 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 used for user-facing progress output in installVerified (helm) In installVerified, replaced π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| pterm.Info.Printf("Downloading verified helm %s...\n", 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.Printf("Installed verified helm %s to %s\n", download.Helm.Version, path) | ||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ func syncOperationPatch(prune bool) string { | |
| func (m *Manager) RefreshAndSync(ctx context.Context, prune bool) error { | ||
| if m.dynamicClient == nil { | ||
|
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. 𦩠π initKubernetesClients error returned bare without wrapping in RefreshAndSync In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if err := m.initKubernetesClients(); err != nil { | ||
| return err | ||
| return fmt.Errorf("initializing kubernetes clients: %w", err) | ||
| } | ||
| } | ||
| if m.dynamicClient == nil { | ||
|
|
@@ -85,7 +85,7 @@ func (m *Manager) RefreshAndSync(ctx context.Context, prune bool) error { | |
| // 2) Don't clobber an operation already in flight β setting .operation over a | ||
| // running one is racy; wait briefly, then refuse rather than stomp it. | ||
| if err := m.ensureNoRunningOperation(ctx, budget); err != nil { | ||
|
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. 𦩠π΅ ensureNoRunningOperation error returned bare without wrapping In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| return err | ||
| return fmt.Errorf("waiting for in-flight operation to clear: %w", err) | ||
| } | ||
|
|
||
| // 3) Trigger the sync via the top-level .operation field. | ||
|
|
@@ -327,7 +327,7 @@ func (m *Manager) SyncApplications(ctx context.Context, names []string) error { | |
| func (m *Manager) syncApplicationsByName(ctx context.Context, names []string, prune bool) (patched, failed int, firstErr error) { | ||
| if m.dynamicClient == nil { | ||
|
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. 𦩠π΅ syncApplicationsByName propagates initKubernetesClients error unwrapped In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if err := m.initKubernetesClients(); err != nil { | ||
| return 0, len(names), err | ||
| return 0, len(names), fmt.Errorf("initializing kubernetes clients: %w", err) | ||
| } | ||
| } | ||
| apps := m.dynamicClient.Resource(applicationGVR).Namespace(ArgoCDNamespace) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,7 +154,7 @@ func (h *HelmManager) IsChartInstalled(ctx context.Context, releaseName, namespa | |
| Env: h.getHelmEnv(), | ||
| }) | ||
| if err != nil { | ||
| return false, err | ||
| return false, fmt.Errorf("checking install status of release %s in namespace %s: %w", releaseName, namespace, err) | ||
| } | ||
|
|
||
| releases := strings.Split(strings.TrimSpace(result.Stdout), "\n") | ||
|
Comment on lines
154
to
160
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. 𦩠π΅ IsChartInstalled returns helm errors unwrapped, losing call-site context In IsChartInstalled (internal/chart/providers/helm/manager.go), wrapped the raw error from h.executor.ExecuteWithOptions with fmt.Errorf("checking install status of release %s in namespace %s: %w", releaseName, namespace, err) before returning, matching the error-wrapping convention used elsewhere in the file (e.g. UninstallRelease, GetChartStatus). No other logic changed. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
@@ -842,3 +842,4 @@ func (h *HelmManager) convertWindowsPathToWSL(windowsPath string) (string, error | |
|
|
||
| return path, nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,7 +209,7 @@ func (d *GKEDiscoverer) Discover(ctx context.Context) (Result, error) { | |
| } | ||
| var clusters []gkeCluster | ||
|
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. 𦩠π΅ describe() in gke.go returns unwrapped errors from json.Unmarshal in Discover's inline path In GKEDiscoverer.Discover (internal/cluster/discovery/gke.go), the json.Unmarshal error-handling branch for the clusters list now includes the underlying error via π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer |
||
| if err := json.Unmarshal([]byte(result.Stdout), &clusters); err != nil { | ||
| res.Warnings = append(res.Warnings, fmt.Sprintf("%s: unparseable clusters list", project)) | ||
| res.Warnings = append(res.Warnings, fmt.Sprintf("%s: unparseable clusters list: %v", project, err)) | ||
| continue | ||
| } | ||
| for _, c := range clusters { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,11 @@ func ParseBackendURL(raw string) (BackendConfig, error) { | |
| // the rendered HCL for their provider's backend type. | ||
| func (w *Workspace) WriteBackend(backendTF []byte) error { | ||
|
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. 𦩠π΅ WriteBackend returns bare os errors without wrapping In WriteBackend (internal/cluster/providers/terraform/backend.go), wrapped the os.MkdirAll error with fmt.Errorf("creating terraform dir: %w", err) and the os.WriteFile error with fmt.Errorf("writing backend.tf: %w", err), matching the suggested fix exactly; fmt was already imported. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if err := os.MkdirAll(w.TerraformDir(), 0o750); err != nil { | ||
| return err | ||
| return fmt.Errorf("creating terraform dir: %w", err) | ||
| } | ||
| return os.WriteFile(filepath.Join(w.TerraformDir(), "backend.tf"), backendTF, 0o600) | ||
| if err := os.WriteFile(filepath.Join(w.TerraformDir(), "backend.tf"), backendTF, 0o600); err != nil { | ||
| return fmt.Errorf("writing backend.tf: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,12 +50,12 @@ func EstimateMonthlyCost(ctx context.Context, execer sharedexec.CommandExecutor, | |
| } | ||
| tmp, err := os.MkdirTemp("", "openframe-infracost-*") | ||
|
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. 𦩠π΅ EstimateMonthlyCost swallows context on several os/json errors In EstimateMonthlyCost (internal/cluster/providers/terraform/cost.go), wrapped the os.MkdirTemp error with "creating temp dir: %w" and the os.WriteFile error with "writing plan json: %w" using fmt.Errorf, matching the style already used for the infracost breakdown and json unmarshal errors in the same function. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| return "", err | ||
| return "", fmt.Errorf("creating temp dir: %w", err) | ||
| } | ||
| defer func() { _ = os.RemoveAll(tmp) }() | ||
| planPath := filepath.Join(tmp, "plan.json") | ||
| if err := os.WriteFile(planPath, planJSON, 0o600); err != nil { | ||
| return "", err | ||
| return "", fmt.Errorf("writing plan json: %w", err) | ||
| } | ||
|
|
||
| // A local bound: infracost calls its pricing API over the network, and a | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package terraform | |
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "io/fs" | ||
| "os" | ||
| "path/filepath" | ||
|
|
@@ -22,10 +23,10 @@ func CopyPlanInputs(srcDir, dstDir string) error { | |
| continue | ||
| } | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("reading %s: %w", name, err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join(dstDir, name), data, 0o600); err != nil { // #nosec G703 -- dstDir is our own MkdirTemp dir; srcDir is CLI-managed under ~/.openframe | ||
| return err | ||
| return fmt.Errorf("writing %s: %w", name, err) | ||
| } | ||
| } | ||
| return nil | ||
|
Comment on lines
23
to
32
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. 𦩠π΅ CopyPlanInputs returns bare os error without context wrapping In CopyPlanInputs (internal/cluster/providers/terraform/preview.go), wrapped the os.ReadFile error with fmt.Errorf("reading %s: %w", name, err) and the os.WriteFile error with fmt.Errorf("writing %s: %w", name, err), adding the "fmt" import, so both failure paths identify the filename and operation at the call boundary. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,11 +268,11 @@ func writeFileAtomic(body []byte, destPath string, perm os.FileMode) error { | |
| if _, err := tmp.Write(body); err != nil { | ||
|
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. 𦩠π΅ writeFileAtomic returns bare write/close errors without wrapping context In writeFileAtomic (internal/shared/download/verify.go), wrapped the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| _ = tmp.Close() | ||
| cleanup() | ||
| return err | ||
| return fmt.Errorf("writing temp file: %w", err) | ||
| } | ||
| if err := tmp.Close(); err != nil { | ||
| cleanup() | ||
| return err | ||
| return fmt.Errorf("closing temp file: %w", err) | ||
| } | ||
| if err := os.Chmod(tmpName, perm); err != nil { | ||
| cleanup() | ||
|
|
||
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.
𦩠π΅ UserBinDir error returned bare without context wrapping
In installVerified (internal/chart/prerequisites/helm/helm.go), wrapped the bare
return errfrom download.UserBinDir() withfmt.Errorf("resolving user bin dir: %w", err), matching the suggested fix exactly.π€ Prompt for AI agents
fix confidence: π’ 95 high β react π/π to teach the reviewer