Skip to content

fix(adhoc-sweep-fixes): 3 review findings across 3 files - #353

Draft
flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-675b4ef6-91c75a3f
Draft

fix(adhoc-sweep-fixes): 3 review findings across 3 files#353
flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-675b4ef6-91c75a3f

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes 3 review findings across 3 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🔴 25 low — review closely gke/kubeconfig.go and eks/kubeconfig.go duplicate caData/kubeconfigFor/restConfigFor/merge/remove logic almost verbatim internal/cluster/providers/gke/kubeconfig.go:1
2 🔴 55 low — review closely isSystemNamespace / appNamespacesToDelete / countDeletablePVs duplicated verbatim between EKS and GKE teardown packages internal/cluster/providers/gke/teardown.go:47
3 🟡 85 medium containsSubstring helper duplicated verbatim across four test files internal/cluster/prerequisites/k3d/k3d_test.go:79

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 91c75a3f-4f00-4dd6-9120-a00ab67ad34d

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

3 finding(s) fixed in this draft — 3 explained inline on the diff; 2 low-confidence hunk(s) need close review before merging.

@@ -1,13 +1,11 @@
package gke

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 gke/kubeconfig.go and eks/kubeconfig.go duplicate caData/kubeconfigFor/restConfigFor/merge/remove logic almost verbatim

Refactored internal/cluster/providers/gke/kubeconfig.go to delegate caData, kubeconfigFor, restConfigFor, mergeIntoDefaultKubeconfig, and removeFromDefaultKubeconfig to a new shared package internal/cluster/providers/kubeconfig (referenced as kubeconfighelper), parameterized by an ExecConfig factory function, exactly as the finding suggested. However, this fix is INCOMPLETE and RISKY as delivered: I was only permitted to touch this one file, so the shared package internal/cluster/providers/kubeconfig (with exported CAData, KubeconfigFor, RestConfigFor, MergeIntoDefaultKubeconfig, RemoveFromDefaultKubeconfig functions matching these exact signatures) does not exist yet and must be created separately — this file will not compile until that companion package is added. The EKS file (eks/kubeconfig.go) also still needs to be migrated to use the same helper to fully resolve the duplication; that is out of scope here since only the GKE file could be edited. A complete fix requires: (a) creating the internal/cluster/providers/kubeconfig package with the extracted logic taking an ExecConfigFactory func(tfengine.Record) *clientcmdapi.ExecConfig parameter, and (b) updating eks/kubeconfig.go to use it too.

🤖 Prompt for AI agents
In internal/cluster/providers/gke/kubeconfig.go around line 1, review and complete this code-review fix: gke/kubeconfig.go and eks/kubeconfig.go duplicate caData/kubeconfigFor/restConfigFor/merge/remove logic almost verbatim.
What the draft fix changed: Refactored `internal/cluster/providers/gke/kubeconfig.go` to delegate `caData`, `kubeconfigFor`, `restConfigFor`, `mergeIntoDefaultKubeconfig`, and `removeFromDefaultKubeconfig` to a new shared package `internal/cluster/providers/kubeconfig` (referenced as `kubeconfighelper`), parameterized by an `ExecConfig` factory function, exactly as the finding suggested. However, this fix is INCOMPLETE and RISKY as delivered: I was only permitted to touch this one file, so the shared package `internal/cluster/providers/kubeconfig` (with exported `CAData`, `KubeconfigFor`, `RestConfigFor`, `MergeIntoDefaultKubeconfig`, `RemoveFromDefaultKubeconfig` functions matching these exact signatures) does not exist yet and must be created separately — this file will not compile until that companion package is added. The EKS file (`eks/kubeconfig.go`) also still needs to be migrated to use the same helper to fully resolve the duplication; that is out of scope here since only the GKE file could be edited. A complete fix requires: (a) creating the `internal/cluster/providers/kubeconfig` package with the extracted logic taking an `ExecConfigFactory func(tfengine.Record) *clientcmdapi.ExecConfig` parameter, and (b) updating `eks/kubeconfig.go` to use it too.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 25 low — review closely — react 👍/👎 to teach the reviewer

// isSystemNamespace reports whether ns is a cluster/system namespace that
// teardown must never delete.
func isSystemNamespace(ns string) bool {
if _, ok := systemNamespaces[ns]; ok {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 isSystemNamespace / appNamespacesToDelete / countDeletablePVs duplicated verbatim between EKS and GKE teardown packages

Extracted isSystemNamespace, appNamespacesToDelete, and countDeletablePVs (and the systemNamespaces base map) into a new shared package internal/cluster/providers/shared (referenced here as shared.AppNamespacesToDelete / shared.CountDeletablePVs, parameterized by systemNamespacePrefixes), removed the duplicated function bodies and the systemNamespaces var from internal/cluster/providers/gke/teardown.go, kept the GKE-specific systemNamespacePrefixes ("gke-", "gmp-") local, added the shared import, and updated call sites in releaseWorkloadDisks. This assumes a corresponding new file internal/cluster/providers/shared/namespaces.go (not shown/created here since only this one file could be edited) exporting AppNamespacesToDelete(all []string, extraPrefixes []string) []string, CountDeletablePVs(pvs []corev1.PersistentVolume) int, and an internal base system-namespace set including "kube-"/"default"/etc. Since the task scope is restricted to this single file, the shared package itself is NOT created/verified here — this file will not compile until internal/cluster/providers/shared is added with matching exported signatures, and the EKS file still needs the same migration to actually eliminate the duplication. Risk: build-breaking until the shared package exists; a complete fix requires editing at least 3 files total (this one, eks/teardown.go, and the new shared package), which exceeds the single-file constraint given.

🤖 Prompt for AI agents
In internal/cluster/providers/gke/teardown.go around line 47, review and complete this code-review fix: isSystemNamespace / appNamespacesToDelete / countDeletablePVs duplicated verbatim between EKS and GKE teardown packages.
What the draft fix changed: Extracted `isSystemNamespace`, `appNamespacesToDelete`, and `countDeletablePVs` (and the `systemNamespaces` base map) into a new shared package `internal/cluster/providers/shared` (referenced here as `shared.AppNamespacesToDelete` / `shared.CountDeletablePVs`, parameterized by `systemNamespacePrefixes`), removed the duplicated function bodies and the `systemNamespaces` var from `internal/cluster/providers/gke/teardown.go`, kept the GKE-specific `systemNamespacePrefixes` (`"gke-", "gmp-"`) local, added the `shared` import, and updated call sites in `releaseWorkloadDisks`. This assumes a corresponding new file `internal/cluster/providers/shared/namespaces.go` (not shown/created here since only this one file could be edited) exporting `AppNamespacesToDelete(all []string, extraPrefixes []string) []string`, `CountDeletablePVs(pvs []corev1.PersistentVolume) int`, and an internal base system-namespace set including `"kube-"`/`"default"`/etc. Since the task scope is restricted to this single file, the shared package itself is NOT created/verified here — this file will not compile until `internal/cluster/providers/shared` is added with matching exported signatures, and the EKS file still needs the same migration to actually eliminate the duplication. Risk: build-breaking until the shared package exists; a complete fix requires editing at least 3 files total (this one, eks/teardown.go, and the new shared package), which exceeds the single-file constraint given.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

Comment on lines 90 to 92
t.Errorf("no pinned k3d asset for %s/%s", runtime.GOOS, runtime.GOARCH)
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔵 containsSubstring helper duplicated verbatim across four test files

Removed the duplicated containsSubstring helper function from internal/cluster/prerequisites/k3d/k3d_test.go and replaced all three call sites (TestK3dInstaller_GetInstallHelp, TestK3dInstaller_Install) with the standard library's strings.Contains, which has identical semantics. Added "strings" to the import block. This eliminates this file's copy of the duplicated boilerplate; the other files mentioned in the finding (docker_test.go, installer_test.go) are outside the scope of this single-file fix and would need the same treatment separately.

🤖 Prompt for AI agents
In internal/cluster/prerequisites/k3d/k3d_test.go around line 79, review and complete this code-review fix: containsSubstring helper duplicated verbatim across four test files.
What the draft fix changed: Removed the duplicated `containsSubstring` helper function from `internal/cluster/prerequisites/k3d/k3d_test.go` and replaced all three call sites (`TestK3dInstaller_GetInstallHelp`, `TestK3dInstaller_Install`) with the standard library's `strings.Contains`, which has identical semantics. Added `"strings"` to the import block. This eliminates this file's copy of the duplicated boilerplate; the other files mentioned in the finding (docker_test.go, installer_test.go) are outside the scope of this single-file fix and would need the same treatment separately.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants