Repository navigation
Conversation
`state: absent` on a dropdown choice is how a schema file removes that choice. The generated `DropdownChoiceWrite` model now declares `state` (enum `SchemaState`, default `present`), so `validate_schema` accepts it without the read-only warning and only `id` stays read-only on a choice. The read model is unchanged, so the schema read API does not return `state` on choices. `infrahubctl schema format` now places `state` after the other keys of a choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
e5d1ed6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://430ed244.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pog-em-dropdown-choice-state.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1498 +/- ##
====================================================
- Coverage 87.85% 87.84% -0.01%
====================================================
Files 157 157
Lines 15656 15654 -2
Branches 2114 2114
====================================================
- Hits 13754 13752 -2
Misses 1341 1341
Partials 561 561
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A team removes one dropdown choice by setting
state: absenton it in a schema file. The SDK write model of a choice has nostatefield, sovalidate_schemareportschoices.stateas a read-only field and Infrahub ignores the value. This PR addsstatetoDropdownChoiceWrite. The Infrahub change that removes the choice is in opsmill/infrahub#11493. The analysis is in opsmill/infrahub#10938.Changes to the generated write contract
DropdownChoiceWritedeclaresstate(enumSchemaState, defaultpresent). The field is generated from thestatefield of attributes in Infrahub'sinternal.py.READ_ONLY_FIELDS["DropdownChoiceWrite"]now lists onlyid.DropdownChoiceReadis unchanged, so the schema read API does not returnstateon choices.Changes to validation and formatting results
validate_schemaacceptsstate: absenton a choice without a warning.statevalue other thanpresentorabsenton a choice is reported as an error.infrahubctl schema formatplacesstateafter the other keys of a choice.Tests
tests/unit/test_schema_offline_validation.py:idto be reported as read-only;state: absenton a Dropdown choice is accepted without a warning;statevalue outside the enum is reported as an error.tests/unit/ctl/test_schema_format.py: new test for the position ofstatein a choice. It fails without theCHOICE_ORDERchange.🤖 Generated with Claude Code