TestServe started the server in a goroutine that captured Serve's
return value, slept two seconds, then called assert.NoError on it. The
test body returned immediately after Shutdown without ever joining that
goroutine, so the assertion ran after the test had already been recorded
as passed and could never affect its result (a dead assertion). It was
also wrong: closing the listener in Shutdown makes Serve return a
net.ErrClosed error, not nil.
Capture Serve's error over a buffered channel and assert it synchronously
in the test body after Shutdown, checking it wraps net.ErrClosed so the
check actually runs within the test's lifetime and catches an unexpected
Serve failure.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
RunCustomAnalysis built its worker semaphore directly from the unvalidated
a.MaxConcurrency field, unlike RunAnalysis which clamps the value first. With
the user-supplied --max-concurrency flag this caused two failures:
- --max-concurrency 0 makes an unbuffered channel, so the pre-send blocks
waiting for a receiver that is only launched on the next line, deadlocking
the whole analyze command whenever a custom analyzer is configured.
- --max-concurrency -1 makes make(chan struct{}, -1) panic with
"makechan: size out of range".
Apply the same lower/upper bound clamp RunAnalysis already uses (default 10 for
non-positive values, cap at 100). Add regression tests covering both cases.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
TestHPAAnalyzerWithExistingScaleTargetRefWithoutSpecifyingResources placed
its "if !errorFound { t.Error(...) }" assertion inside the outer
"for _, analysis := range analysisResults" loop. When the analyzer emits
zero results (exactly the regression this test guards against, the
"does not have resource configured." detection breaking), the outer loop
body never runs, the assertion is skipped, and the test passes green.
Move the assertion after the outer loop and break out of it once the error
is found, matching the sibling HPA tests (TestHPAAnalyzerWithUnsuportedScaleTargetRef,
TestHPAAnalyzerWithNonExistentScaleTargetRef). Also drop the dead break that
sat inside the inner loop after its own break. Test-only change.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
The EKS integration analyzer built the default kubeconfig path from
os.Getenv("HOME") when no explicit --kubeconfig was provided. On Windows
the HOME environment variable is normally unset (Windows exposes
USERPROFILE, and HOMEDRIVE plus HOMEPATH), so os.Getenv("HOME") returned
"" and filepath.Join collapsed to the relative path .kube/config resolved
against the current working directory rather than the user's home. The
analyzer then loaded an empty config and reported "EKS cluster was not
detected" even when a valid ~/.kube/config existed.
Resolve the home directory with os.UserHomeDir() instead, matching the
convention already used elsewhere in the codebase (cmd/root.go), so the
default kubeconfig path works on Windows as well as Unix. The path
resolution is extracted into a small getKubeconfigPath helper and covered
by a unit test.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
The Deployment analyzer dereferenced *deployment.Spec.Replicas without a
nil check. Spec.Replicas is a *int32 and, although the API server usually
defaults it to 1, a Deployment object whose replicas field is explicitly
unset (nil) panics the analyze run with a nil pointer dereference.
Guard the comparison with a nil check, mirroring the sibling StatefulSet
analyzer which already checks Spec.Replicas != nil before dereferencing.
Add a regression test that analyzes a Deployment with nil Spec.Replicas
and asserts Analyze does not panic.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
The extra-files list in release-please-config.json referenced four paths
that do not exist in the repository (deploy/manifest.yaml, chart/Chart.yaml,
chart/values.yaml, container/manifests/deployment.yaml). release-please
silently skips missing extra-files (createIfMissing is false), so the
#x-release-please-version marker in charts/k8sgpt/Chart.yaml was never
bumped and its appVersion stayed frozen at v0.4.23 while releases advanced
to v0.4.35.
Because the chart's default image tag falls back to .Chart.AppVersion, a
default install of charts/k8sgpt deployed a stale image and stamped
app.kubernetes.io/version: v0.4.23 on the rendered resources.
Point extra-files at the file that actually carries the marker
(charts/k8sgpt/Chart.yaml) and bump appVersion to the current v0.4.35 so
the chart is correct now and release-please keeps it in sync going forward.
List the chart with type "generic" rather than as a plain string. A plain
.yaml string makes release-please run GenericYaml($.version) before the
Generic updater; GenericYaml re-serializes the document with a parser that
drops all comments, which would delete the #x-release-please-version marker
and rewrite the unrelated chart version field. The generic type runs only
the comment-aware Generic updater, so it bumps appVersion on the annotated
line and leaves the marker and the chart version intact. charts/k8sgpt/
values.yaml has no version marker, so it is not listed.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Upstream k8s.io dependencies have moved past Go 1.24, so every Renovate
PR touching them now drags the go directive forward and fails lint under
the pinned golangci-lint v2.1.0 (built with go1.24). This unblocks
#1678, #1570, #1688 and #1346.
- go.mod: go 1.26.3, toolchain go1.26.5 (matches Renovate's rebases)
- golangci-lint: v2.1.0 -> v2.12.2 (built with go1.26)
- CI workflows: Go ~1.24 -> ~1.26
- container builder image: golang:1.26-alpine3.23
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The two Vertex AI "Legacy Stable Model" constants carried a trailing '*'
that leaked in from the footnote marker in Google's model-versions table:
ModelGeminiProV1_5 was "gemini-1.5-pro-002*" and ModelGeminiFlashV1_5 was
"gemini-1.5-flash-002*". The '*' is not part of the model id.
GetVertexAIModelOrDefault does an exact-match lookup and otherwise silently
returns VERTEXAI_MODELS[0]. Because VERTEXAI_MODELS held the asterisked
values, a user who correctly configured --model gemini-1.5-pro-002 failed
the exact match and was silently switched to the default model, so the two
legacy models could never be selected.
Remove the trailing '*' from both literals and add a unit test covering the
model and region resolvers.
Closes#1516
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
grpc.NewClient returns a nil *ClientConn when it fails (for example on an
invalid connection string). Store and Load registered defer conn.Close()
before checking the returned error, so a client-creation failure triggered a
nil pointer dereference in the deferred Close instead of returning the error.
Move defer conn.Close() to after the error check in both methods. Add a
regression test that drives Store and Load with an invalid connection string
and asserts they return an error without panicking.
The deferred conn.Close() now discards its error with a plain _ = conn.Close()
rather than logging it: grpc's ClientConn.Close() only returns a non-nil error
on a double-close, which can't happen from a single call site here, so a
logging branch would be dead code that patch coverage can never satisfy.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
The Service analyzer dereferenced EndpointAddress.TargetRef while building
the not-ready pod list, but TargetRef is optional and can be nil for
addresses not backed by a Pod (bare-IP or manually created Endpoints).
A single such address panicked the whole analyze run with a nil pointer
dereference. Only append the pod label when TargetRef is set; the address
is still counted so the failure message is unchanged. Adds a regression
test covering a not-ready address with no TargetRef.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
The Gateway and GatewayClass analyzers indexed Status.Conditions[0]
without a length check. A Gateway or GatewayClass with empty
Status.Conditions (newly created, or no controller installed) panics
the whole analyze run with 'index out of range [0] with length 0'.
Guard both accesses with a length check, mirroring the existing PDB
analyzer (pkg/analyzer/pdb.go). Add a unit test for each analyzer that
exercises the empty-conditions path.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
A pod with non-empty .spec.schedulingGates stays in the Pending phase
with a PodScheduled condition of Status=False, Reason=SchedulingGated.
The pod analyzer only matched the Unschedulable reason, so a gated pod
fell through every branch and was reported as having no problems.
Add a sibling check on the PodScheduled condition for the
SchedulingGated reason. Gated pods commonly carry an empty condition
message, so emit a default message naming the pod when none is present
and surface the condition message otherwise, mirroring how the
Unschedulable branch reports.
This is the residual half of #1474; the suspended Job/CronJob half is
already handled in job.go and cronjob.go.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>
* fix(deps): update module github.com/olekukonko/tablewriter to v1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix(cache): migrate to tablewriter v1 API
tablewriter v1 replaces SetHeader with Header and makes Append/Render
return errors. Update cmd/cache/list.go accordingly to fix the build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Alex Jones <axjns@example.com>
---------
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Alex Jones <axjns@example.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alex Jones <axjns@example.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implement the Anthropic backend client for Claude models, including:
- AnthropicClient with Configure/GetCompletion/GetName methods
- Proxy, custom headers, and base URL support
- Default model (claude-3-5-sonnet-latest) fallback in auth add command
- Unit tests with httptest mock server
Signed-off-by: Alex <alexsimonjones@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FOSSA is not a CNCF requirement for sandbox projects. The badge/check
was failing on unrelated third-party licenses with no actionable items
for the k8sgpt maintainers.
Changes:
- Removed FOSSA shield badge from README header
- Removed FOSSA large badge from the License section
- Removed section heading (was only used for the FOSSA badge)
- Removed License entry from the TOC
The project is still licensed under Apache 2.0 (badge and LICENSE file unchanged).
Signed-off-by: Three Foxes (in a Trenchcoat) <threefoxesyes3inatrenchcoat@gmail.com>