Skip to content

Support non-Infra GKE cluster type and allow Unknown as cluster type#254

Merged
mclasmeier merged 1 commit into
mainfrom
mc/gke-cluster-type
Jul 21, 2026
Merged

Support non-Infra GKE cluster type and allow Unknown as cluster type#254
mclasmeier merged 1 commit into
mainfrom
mc/gke-cluster-type

Conversation

@mclasmeier

@mclasmeier mclasmeier commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Support non-Infra GKE cluster type and also support specifying 'Unknown' as a generic type explicitly

Summary by CodeRabbit

  • New Features
    • Added automatic recognition for Google Kubernetes Engine (GKE) environments, including standard and infrastructure GKE contexts.
    • Added support for identifying and displaying GKE cluster types in configuration.
  • Bug Fixes
    • Improved automatic cluster-type detection when no cluster type is configured.
    • Applied appropriate defaults for local and GKE deployments.
    • Improved handling and validation of unknown cluster types.
  • Tests
    • Expanded coverage for GKE detection, configuration defaults, and cluster-type serialization.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Cluster type handling now supports general GKE contexts, represents unknown values as "Unknown", applies predicate-based defaults, and treats empty deployment cluster types as unset during auto-detection.

Changes

Cluster type flow

Layer / File(s) Summary
Cluster type contract
internal/types/cluster_type.go, internal/types/cluster_type_test.go
Unknown and GKE cluster types now have updated string, predicate, list, and YAML serialization behavior.
GKE context detection
internal/env/env.go, internal/env/env_test.go
Contexts beginning with gke_ are classified as GKE, with infra-specific and general GKE detection tests updated.
Deployment defaults and configuration
cmd/deploy.go, internal/clusterdefaults/*
Empty cluster types trigger auto-detection, while local defaults use predicates and GKE defaults are tested explicitly.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant configureConfig
  participant DetectClusterType
  participant ClusterType
  configureConfig->>DetectClusterType: request auto-detected cluster type
  DetectClusterType->>ClusterType: classify gke_ context as GKE
  ClusterType-->>configureConfig: return ClusterTypeGKE
Loading

Possibly related PRs

  • stackrox/roxie#184: Updates related cluster-type handling in deployment configuration and unknown-type stringification.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding non-Infra GKE support and making Unknown an explicit cluster type.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mc/gke-cluster-type

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mclasmeier

Copy link
Copy Markdown
Collaborator Author

@coderabbitai, try again?

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@mclasmeier, retrying the review for #254 now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mclasmeier

Copy link
Copy Markdown
Collaborator Author

@coderabbitai, still rate limited?

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@mclasmeier I don’t have a definitive rate-limit status from the previous attempt—the retry was reported as finished. I’m triggering another review now; its result should confirm whether the limit is still affecting this PR.

🐇💭

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/env/env.go (1)

147-152: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider using contextLower for consistency.

The rest of the heuristics in this function rely on contextLower for case-insensitive matching. Using it here makes the GKE checks more resilient and consistent with the other cluster type checks.

♻️ Proposed refactor
-	if strings.HasPrefix(config.CurrentContext, "gke_acs-team-temp-dev") {
+	if strings.HasPrefix(contextLower, "gke_acs-team-temp-dev") {
 		return types.ClusterTypeInfraGKE
 	}
-	if strings.HasPrefix(config.CurrentContext, "gke_") {
+	if strings.HasPrefix(contextLower, "gke_") {
 		return types.ClusterTypeGKE
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/env/env.go` around lines 147 - 152, Update the GKE prefix checks in
the cluster-type detection function to use the existing contextLower value
instead of config.CurrentContext, preserving the existing infra-GKE precedence
and return values while ensuring case-insensitive matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/env/env.go`:
- Around line 147-152: Update the GKE prefix checks in the cluster-type
detection function to use the existing contextLower value instead of
config.CurrentContext, preserving the existing infra-GKE precedence and return
values while ensuring case-insensitive matching.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: d5422cff-cc29-48ec-8200-f61efdff7af1

📥 Commits

Reviewing files that changed from the base of the PR and between 4f94203 and 0d67aa9.

📒 Files selected for processing (7)
  • cmd/deploy.go
  • internal/clusterdefaults/clusterdefaults.go
  • internal/clusterdefaults/clusterdefaults_test.go
  • internal/env/env.go
  • internal/env/env_test.go
  • internal/types/cluster_type.go
  • internal/types/cluster_type_test.go

@mclasmeier
mclasmeier merged commit 0337b3b into main Jul 21, 2026
12 checks passed
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.

2 participants