Skip to content

Explore/upgrade gofish#131

Open
alexlovelltroy wants to merge 2 commits into
feature/RFD-133-Explorefrom
explore/upgrade-gofish
Open

Explore/upgrade gofish#131
alexlovelltroy wants to merge 2 commits into
feature/RFD-133-Explorefrom
explore/upgrade-gofish

Conversation

@alexlovelltroy

Copy link
Copy Markdown
Member

This pull request introduces significant improvements to the power control command and the BMC (Baseboard Management Controller) client, focusing on vendor-neutral operations, context handling, and dependency updates. The changes modernize the codebase to use the latest libraries, add robust context support for cancellation and deadlines, and enhance test coverage for flag handling and BMC operations.

Key highlights:

  • Adds a new vendor-neutral --operation flag to the power command, with graceful fallback logic.
  • Refactors BMC client methods to take context.Context, enabling cancellation and deadline propagation.
  • Updates dependencies, including gofish, cobra, and viper, to their latest versions.
  • Improves test coverage for CLI flag collisions and BMC client behavior.
  • Cleans up and clarifies flag handling and documentation.

Power command enhancements

  • Adds a vendor-neutral --operation (-o) flag to the power command, allowing users to specify high-level power operations (e.g., on, off, soft-restart), which are resolved to supported Redfish reset types with fallback logic. Also, improves flag validation and help text. (cmd/power.go [1] [2] [3]
  • Removes the -l shorthand for --list-reset-types to avoid collision with the global --log-level flag, and updates usage examples accordingly. (cmd/power.go cmd/power.goL239-R270)

BMC client context support and API improvements

  • Refactors all BMC client methods to accept a context.Context parameter, ensuring that cancellations and timeouts are respected for all BMC operations. (pkg/bmc/client.go [1] [2] [3] [4] [5]
  • Adds a new ResetOperation method that maps vendor-neutral operations to supported Redfish reset types, applying fallback logic, and returns the task monitor for async operations. (pkg/bmc/client.go [1] [2]

Dependency and compatibility updates

  • Updates several dependencies to their latest versions, including gofish (v0.22.0), cobra, viper, and others, ensuring compatibility and access to new features (notably, gofish now returns task monitor info for resets). (go.mod go.modL3-L64)

Improved testing and validation

  • Adds a new test to ensure the power command executes without flag collisions, guarding against regressions with CLI shorthand flags. (cmd/power_test.go cmd/power_test.goR1-R30)
  • Expands BMC client tests to cover context cancellation, system-not-found errors, and correct mapping of vendor-neutral operations to Redfish reset types. (pkg/bmc/client_test.go [1] [2] [3]

Code and documentation cleanup

  • Updates imports and documentation throughout the codebase to reflect the use of schemas instead of the deprecated redfish package, and clarifies context handling semantics. (cmd/power.go [1] pkg/bmc/client.go [2] [3] [4] pkg/bmc/manager.go [5]

These changes collectively improve the flexibility, reliability, and maintainability of the power management subsystem.


For more info, see Contributing Guidelines.

- Updated imports from redfish to schemas in various files to align with the new package structure.
- Modified Client interface methods to return types from schemas instead of redfish.
- Adjusted implementations in GenericClient to accommodate the new schemas types.
- Updated tests to reflect changes in the types used for power states and reset types.
- Refactored functions in collect, crawler, power, service, and update packages to utilize schemas types.
- Introduced helper functions to dereference optional numeric fields for better handling of nil values.

Signed-off-by: Alex Lovell-Troy <alex@lovelltroy.org>
…BMC layer

Signed-off-by: Alex Lovell-Troy <alex@lovelltroy.org>
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.

1 participant