Skip to content

Conversation

@rh-amarin
Copy link
Contributor

Config Refactor based on proposed standard

This PR refactors the configuration system to use https://github.com/spf13/viper for more flexible and maintainable configuration management.

What Changed

  • Configuration Framework: Migrated from environment variable-based config to viper-based system
  • Command-Specific Config: Added specialized config structs for migrate and serve commands
  • Config Endpoint: Added HTTP endpoint to expose runtime configuration
  • Documentation: Comprehensive config documentation added

How to Review This PR

The commits are organized in a logical sequence to make reviewing easier. Review them in order:

1️⃣ Dependencies (Commit 1)

Files: go.mod, go.sum
Focus: Verify viper and related dependencies are appropriate

2️⃣ Documentation & Template (Commit 2)

Files: configs/config.yaml, docs/config.md
Focus:

  • Review the config file structure and defaults
  • Ensure documentation is clear and comprehensive
  • Validate that all config options are documented

3️⃣ New Config Components (Commit 3)

Files: pkg/config/app.go, pkg/config/migrate_config.go, pkg/config/serve_config.go, tests
Focus:

  • Review new config struct design
  • Check test coverage for new components
  • Validate command-specific config separation makes sense

4️⃣ Core Config Refactor (Commit 4)

Files: pkg/config/*.go
Focus:

  • Review viper integration in existing config components
  • Check backward compatibility with existing env vars
  • Validate config loading and validation logic
  • Review updated tests

5️⃣ Config Handlers (Commit 5)

Files: pkg/handlers/config.go, pkg/handlers/config_test.go
Focus:

  • Review HTTP endpoint implementation
  • Check security considerations (what config data is exposed)
  • Validate test coverage

6️⃣ Environment Framework (Commit 6)

Files: cmd/hyperfleet-api/environments/*.go
Focus:

  • Review environment-specific config changes
  • Ensure simplification maintains necessary functionality

7️⃣ Command Updates (Commit 7)

Files: cmd/hyperfleet-api/migrate/cmd.go, cmd/hyperfleet-api/servecmd/cmd.go
Focus:

  • Review how commands initialize and use new config system
  • Check error handling

8️⃣ Server Components (Commit 8)

Files: cmd/hyperfleet-api/server/*.go
Focus:

  • Review server initialization with new config
  • Check that config endpoint is properly registered

9️⃣ Test Updates (Commit 9)

Files: test/helper.go, test/integration/*.go
Focus:

  • Review test helper updates
  • Ensure integration tests work with new config system

🔟 Build System (Commit 10)

Files: Makefile
Focus:

  • Review Makefile changes
  • Verify build and test targets still work correctly

Testing Checklist

  • All unit tests pass
  • Integration tests pass
  • Config can be loaded from file
  • Config can be loaded from environment variables
  • Config validation works correctly
  • Config endpoint returns expected data
  • Backward compatibility with existing env vars maintained

Acceptance Criteria

  • New viper-based config system is functional
  • All existing functionality works with new config system
  • Config documentation is complete
  • Test coverage is maintained or improved
  • No breaking changes to existing deployments

rh-amarin and others added 10 commits January 5, 2026 12:36
Add viper for configuration management and other required dependencies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add default config.yaml template and comprehensive documentation
explaining the new configuration system.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add specialized config structs for different commands:
- app.go: Application-level config
- migrate_config.go: Migration command config
- serve_config.go: Serve command config
- Corresponding test files with comprehensive coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Refactor all config components to integrate with viper-based
configuration system:
- config.go: Core config loading and validation
- db.go: Database configuration
- health_check.go: Health check configuration
- metrics.go: Metrics configuration
- ocm.go: OCM configuration
- server.go: Server configuration
- config_test.go: Updated tests for new system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add HTTP handlers to expose configuration via API endpoint
for runtime inspection and debugging.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Refactor environment framework to integrate with the new
viper-based configuration system. Simplify environment-specific
configurations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update migrate and serve commands to use the new configuration
framework with command-specific config structs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update API, healthcheck, and metrics servers to use the new
configuration system. Add config endpoint to routes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update test helpers to work with new config system and fix
integration tests to use updated configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update build and test targets to support the new configuration
system and testing requirements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci
Copy link

openshift-ci bot commented Jan 5, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link

openshift-ci bot commented Jan 5, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 86254860 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant