Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASMCMS-9161: Correct type hint, change Enum to IntEnum to allow inequalities #380

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.30.3] - 2024-10-10
### Changed
- Changed `BootSetStatus` type from Enum to IntEnum, to allow inequality comparisons
- Reverted change in `2.30.1` now that inequalities work as expected

### Fixed
- Fixed type hint for `validate_boot_sets` function

## [2.30.2] - 2024-10-09
### Changed
- If an image artifact lacks `boot_parameters`, log this as informational instead of a warning.
Expand Down
5 changes: 3 additions & 2 deletions src/bos/server/controllers/v2/boot_set/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
# OTHER DEALINGS IN THE SOFTWARE.
#

from enum import Enum
from enum import IntEnum
import logging

LOGGER = logging.getLogger('bos.server.controllers.v2.boot_set')

class BootSetStatus(Enum):
# Use IntEnum to allow for inequalities
class BootSetStatus(IntEnum):
"""
In ascending order of error severity
"""
Expand Down
2 changes: 1 addition & 1 deletion src/bos/server/controllers/v2/boot_set/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
def validate_boot_sets(session_template: dict,
operation: str,
template_name: str,
options_data: OptionsData|None=None) -> tuple[str, BootSetStatus]:
options_data: OptionsData|None=None) -> tuple[BootSetStatus, str]:
"""
Validates the boot sets listed in a session template.
This is called when creating a session or when using the sessiontemplatesvalid endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/bos/server/controllers/v2/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def post_v2_session(): # noqa: E501
# Validate health/validity of the sessiontemplate before creating a session
error_code, msg = validate_boot_sets(session_template, session_create.operation, template_name,
options_data=options_data)
if error_code == BootSetStatus.ERROR:
if error_code >= BootSetStatus.ERROR:
LOGGER.error("Session template fails check: %s", msg)
return msg, 400

Expand Down
Loading