Skip to content

Onboarding: Replace flavor selection logic with value#272

Merged
fwiesel merged 1 commit intomainfrom
flavor-config
Mar 18, 2026
Merged

Onboarding: Replace flavor selection logic with value#272
fwiesel merged 1 commit intomainfrom
flavor-config

Conversation

@fwiesel
Copy link
Contributor

@fwiesel fwiesel commented Mar 18, 2026

The logic was unfortunately brittle, so let's drop it with a configuration value.

Summary by CodeRabbit

  • Refactor

    • Simplified test environment initialization by replacing dynamic flavor discovery with a fixed configuration approach. This reduces complexity in the onboarding process and improves setup consistency.
  • Tests

    • Updated test cases to align with the new test environment configuration method.

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

The PR replaces dynamic OpenStack flavor discovery logic with a static TestFlavorID field on the OnboardingController, removing the findTestFlavor function and eliminating API calls to the flavors endpoint. Flavor selection is now configured as a controller field with a default value of "1".

Changes

Cohort / File(s) Summary
Controller Implementation
internal/controller/onboarding_controller.go
Removed the findTestFlavor function and the flavors package import. Added a new public TestFlavorID string field to OnboardingController. Modified createOrGetTestServer to use the field instead of dynamically discovering flavors. SetupWithManager now sets a default value of "1" for TestFlavorID.
Controller Tests
internal/controller/onboarding_controller_test.go
Updated OnboardingController initialization to include TestFlavorID: "1". Removed mocking of the /flavors/detail API endpoint in two test locations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A flavor once sought through the network so wide,
Now sits as a field, with simplicity as guide,
No more API chasing for "1" we rely,
Configuration over discovery—a happy rabbit's sigh! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing dynamic flavor discovery logic with a configurable value (TestFlavorID field).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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 flavor-config
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

The logic was unfortunately brittle, so let's drop it in favor of a
configuration value.
@github-actions
Copy link

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller 62.87% (-0.22%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/onboarding_controller.go 53.39% (-1.27%) 236 (-11) 126 (-9) 110 (-2) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/onboarding_controller_test.go

Copy link

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

🧹 Nitpick comments (1)
internal/controller/onboarding_controller_test.go (1)

92-110: Consider removing unused flavorDetailsBody constant.

This constant appears to be dead code after removing the /flavors/detail endpoint mock. Since flavor discovery is now replaced by the configurable TestFlavorID, this mock data is no longer needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/onboarding_controller_test.go` around lines 92 - 110,
Remove the dead constant declaration flavorDetailsBody from the test file since
the /flavors/detail mock was removed and flavor discovery now uses TestFlavorID;
locate the flavorDetailsBody variable in onboarding_controller_test.go and
delete its declaration (and any unused surrounding variables or imports that
become unused as a result), but do not change any tests that rely on
TestFlavorID.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/controller/onboarding_controller_test.go`:
- Around line 92-110: Remove the dead constant declaration flavorDetailsBody
from the test file since the /flavors/detail mock was removed and flavor
discovery now uses TestFlavorID; locate the flavorDetailsBody variable in
onboarding_controller_test.go and delete its declaration (and any unused
surrounding variables or imports that become unused as a result), but do not
change any tests that rely on TestFlavorID.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8bb6dda8-4f59-49c7-9600-a06994557eef

📥 Commits

Reviewing files that changed from the base of the PR and between 9f13080 and 67b504e.

📒 Files selected for processing (2)
  • internal/controller/onboarding_controller.go
  • internal/controller/onboarding_controller_test.go

@fwiesel fwiesel merged commit 40ef4bb into main Mar 18, 2026
7 checks passed
@fwiesel fwiesel deleted the flavor-config branch March 18, 2026 10:53
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