Skip to content

Make cluster type overwritable#184

Merged
mclasmeier merged 23 commits into
mainfrom
mc/cluster-type-overwritable
May 19, 2026
Merged

Make cluster type overwritable#184
mclasmeier merged 23 commits into
mainfrom
mc/cluster-type-overwritable

Conversation

@mclasmeier
Copy link
Copy Markdown
Collaborator

@mclasmeier mclasmeier commented May 15, 2026

This is useful for testing.
A follow-up PR (#186) introduces OpenShift4-specific (non Infra!) specific behaviour, this PR allows testing this change.

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency in cluster type detection throughout deployment workflow by using a single configuration source instead of multiple runtime queries.
    • Enhanced error messages with cluster-type-specific context for better diagnostics.
  • Refactor

    • Internal restructuring to centralize cluster type configuration handling.
  • Tests

    • Updated test coverage for cluster type serialization and deserialization.

Review Change Stack

@mclasmeier mclasmeier requested a review from vladbologa May 15, 2026 08:25
@mclasmeier mclasmeier changed the base branch from main to mc/remove-unused May 15, 2026 08:27
@mclasmeier mclasmeier force-pushed the mc/cluster-type-overwritable branch from 34347ed to a33d6b8 Compare May 15, 2026 08:30
@mclasmeier mclasmeier changed the base branch from mc/remove-unused to main May 15, 2026 10:06
Comment thread internal/types/cluster_type.go Outdated
@mclasmeier mclasmeier requested a review from porridge May 18, 2026 10:29
Comment thread cmd/deploy.go Outdated
Comment thread cmd/deploy.go Outdated
Comment thread cmd/deploy.go Outdated
Comment thread internal/deployer/config.go
Comment thread internal/deployer/deploy_via_operator.go Outdated
Comment thread internal/types/cluster_type.go
mclasmeier and others added 4 commits May 19, 2026 09:20
Co-authored-by: Marcin Owsiany <porridge@redhat.com>
Co-authored-by: Marcin Owsiany <porridge@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@mclasmeier has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 27 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 9bce52dc-eecb-4095-a0d8-a3f0429e705c

📥 Commits

Reviewing files that changed from the base of the PR and between 8307b55 and 9288ca3.

📒 Files selected for processing (9)
  • cmd/deploy.go
  • cmd/env.go
  • internal/deployer/deploy_via_operator.go
  • internal/deployer/deployer.go
  • internal/deployer/operator.go
  • internal/env/env.go
  • internal/env/env_integration_test.go
  • internal/types/cluster_type.go
  • internal/types/cluster_type_test.go
📝 Walkthrough

Walkthrough

This PR consolidates cluster type detection by migrating from repeated environment queries at runtime to a single configured value set during initialization. ClusterType becomes a string-backed YAML-serializable enum, the defaults API reads from config instead of taking a separate parameter, and all deployment logic uses the configured value consistently.

Changes

ClusterType Configuration Consolidation

Layer / File(s) Summary
ClusterType enum migration and YAML serialization
internal/types/cluster_type.go, internal/types/cluster_type_test.go, internal/env/env_test.go
ClusterType changes from int-backed iota to string-backed enum with explicit constants (Unknown, Minikube, K3s, CRC, GKE, EKS, AKS, OpenShift4, InfraGKE, InfraOpenShift4). String() method updated with new capitalization. UnmarshalYAML method added for YAML deserialization and validation. YAML round-trip tests ensure marshaling/unmarshaling correctness.
Cluster defaults API and integration
internal/clusterdefaults/clusterdefaults.go, internal/clusterdefaults/clusterdefaults_test.go, internal/deployer/config.go
ApplyClusterDefaults signature changed to take config as first parameter and read ClusterType from config.Roxie. Error handling wraps deep-copy and merge failures with cluster-type context. Test updated to set config.Roxie.ClusterType before calling function. Config struct fields realigned.
Configuration initialization and cluster type resolution
cmd/deploy.go
configureConfig sets deploySettings.Roxie.ClusterType from env.GetCurrentClusterType() only when unknown, then applies cluster defaults using the resolved type. Error handling returns raw errors without additional wrapping.
Validation flow using configured cluster type
cmd/deploy.go
deployValidate captures ClusterType once from deploySettings.Roxie and uses it consistently throughout containerized-mode OpenShift4 validation and konflux support checks, eliminating inline environment queries.
Deployment operations using configured cluster type
internal/deployer/deployer.go, internal/deployer/deploy_via_operator.go, internal/deployer/operator.go
Replace all env.GetCurrentClusterType() calls with d.config.Roxie.ClusterType. Affected logic includes OpenShift4 credential preparation, image pull secret decisions in deployCentralOperator and deploySecuredClusterOperator, Konflux image rewriting guards, and deployment summary displays. operator.go removes env import dependency.

Sequence Diagram

sequenceDiagram
  participant Deploy as Deployer.Deploy
  participant Operator as operator.go
  participant Summary as Deployment Summary
  Deploy->>Deploy: Check d.config.Roxie.ClusterType for OpenShift4
  Deploy->>Operator: deployCentralOperator with config
  Operator->>Operator: Use d.config.Roxie.ClusterType for pull secrets
  Operator->>Operator: Use d.config.Roxie.ClusterType for Konflux image rewriting
  Deploy->>Summary: Display cluster type from d.config.Roxie.ClusterType
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through config trees,
No more does it query with ease,
Once at the start, the type's declared,
Through YAML it's parsed, prepared,
Now all the deployer paths agree!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 'Make cluster type overwritable' directly and clearly describes the main change: enabling cluster type to be overwritten for testing purposes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mc/cluster-type-overwritable

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@cmd/deploy.go`:
- Around line 350-355: The code only treats types.ClusterTypeUnknown as missing,
but an unset YAML ClusterType unparses to "" so auto-detection is skipped;
update the check around deploySettings.Roxie.ClusterType (the block that calls
env.GetCurrentClusterType()) to treat both empty string and
types.ClusterTypeUnknown as "unknown" (e.g., if deploySettings.Roxie.ClusterType
== "" || deploySettings.Roxie.ClusterType == types.ClusterTypeUnknown) so
getDefaultsForClusterType() receives a valid clusterType; keep the later
assignment to clusterType := deploySettings.Roxie.ClusterType unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 55f138e1-5c57-4633-8146-9ab97ffd84eb

📥 Commits

Reviewing files that changed from the base of the PR and between bec4974 and 8307b55.

📒 Files selected for processing (10)
  • cmd/deploy.go
  • internal/clusterdefaults/clusterdefaults.go
  • internal/clusterdefaults/clusterdefaults_test.go
  • internal/deployer/config.go
  • internal/deployer/deploy_via_operator.go
  • internal/deployer/deployer.go
  • internal/deployer/operator.go
  • internal/env/env_test.go
  • internal/types/cluster_type.go
  • internal/types/cluster_type_test.go

Comment thread cmd/deploy.go
@mclasmeier mclasmeier merged commit befa352 into main May 19, 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