Merge develop into infrahub-develop#914
Merged
ajtmccarty merged 42 commits intoinfrahub-developfrom Apr 3, 2026
Merged
Conversation
…overy Add a new `infrahub` command as a separate entry point alongside `infrahubctl`. While `infrahubctl` targets developers building on top of Infrahub, the new `infrahub` command targets end users who need to query, create, update, and delete data in the Infrahub database. Commands: - `infrahub get <kind> [identifier]` — list or detail view with table/JSON/CSV/YAML output - `infrahub create <kind>` — create objects via --set flags or --file (JSON/YAML) - `infrahub update <kind> <identifier>` — update objects via --set flags or --file - `infrahub delete <kind> <identifier>` — delete with confirmation prompt (--yes to skip) - `infrahub schema list/show` — discover available kinds and their attributes Key features: - Four output formats: table (default TTY), JSON (default piped), CSV, YAML - YAML output uses Infrahub Object format (apiVersion/kind/spec) for round-tripping - Unified --set flag for both attributes and relationships - Reuses existing SDK client, config, and AsyncTyper infrastructure - 87 unit tests, 16 integration tests
- Fix MD060 table column style in plan.md and quickstart.md - Fix MD032 blanks-around-lists in research.md - Fix MD050 strong-style (escaped __init__.py underscores) in tasks.md - Split integration test class to stay under PLR0904 method limit - Make CLI runner tests sync to avoid asyncio.run() nested loop error
- Add 47 new tests (134 total, up from 87) - schema.py: test list/show with mocked client, filter, branch, empty schema - create.py: test --set inline, --file, invalid field, multiple args, branch - update.py: test --set attributes/relationships, --file, branch - delete.py: test --yes, -y, branch, confirmation abort/accept - formatters/__init__.py: test detect_output_format TTY/non-TTY, get_formatter - yaml/csv/table: test many-cardinality rels, empty peers, None values
- Fix MD032 blanks-around-lists in cli-commands.md and data-model.md - Revert SDK ref docs to match stable (CI regenerates with its own mdxify version)
- Add type coercion in parse_set_args (int, float, bool, null) so --set height=190 sends an integer instead of string "190" - Fix MD032 blanks-around-lists in cli-commands.md and data-model.md - Revert SDK ref docs to stable baseline (CI regenerates with its own mdxify version) - Add error output to integration test assertions for debugging
Instead of a separate `infrahub` entry point, register get, create, update, and delete as top-level commands on the existing `infrahubctl` CLI. Add schema list and schema show as subcommands of the existing `infrahubctl schema` group alongside load, check, and export. - Remove infrahub entry point from pyproject.toml - Remove enduser_cli.py and enduser_commands.py - Register commands in cli_commands.py - Merge schema list/show into ctl/schema.py - Update all tests to use cli_commands.app
- Expose command functions as module-level names (get, create, update, delete) in cli_commands.py so typer --func can find them for doc gen - Generate CLI docs for new commands (get, create, update, delete) and updated schema docs (list, show subcommands added) - Fix test_version to use 'version' subcommand instead of --version flag
Remove Args sections from command docstrings since typer generates help text from Option/Argument annotations. The Args sections leaked Python parameter names (filter_args, set_args, filter_text) and technical terms (substring) into the generated MDX docs, triggering vale spelling errors in CI.
Add --all-columns flag to `infrahubctl get`. By default, columns where every value is empty are suppressed in table and CSV output, making wide schemas with sparse data much more readable. Use --all-columns to show every column. JSON and YAML output always includes all fields.
- Exit code 80 when query succeeds but returns zero results (exit 0 when results found, exit 1 on errors) - Print "No objects of kind <X> found." to stderr on empty results - Show "<N> object(s) found." footer in table output - Empty table still renders column headers so the user sees the kind name and knows the command ran
Add resolve_node() helper that tries multiple lookup strategies: 1. UUID if identifier looks like one 2. Schema default_filter (e.g., name__value) as keyword filter 3. Human-friendly ID (single or multi-component with / separator) This allows commands like `infrahubctl get DcimDevice arista-switch-01` to work using the device name, not just UUID. Applied to get, update, and delete commands.
- Omit empty/null attribute values instead of writing empty strings
(fixes BigInt validation errors on reload)
- Omit unset relationships instead of writing empty strings or {data: []}
- Use HFID for relationship references: single-component as string,
multi-component as list (fixes HFID element count mismatch errors)
- Preserve falsy-but-valid values (0, False)
Replace typer.BadParameter with console.print + typer.Exit for create/update validation errors. BadParameter was caught by the generic exception handler which printed a full traceback. Now shows a clean error message with usage example.
When using --set location=LON-1, the CLI now resolves the relationship target by searching for the node across all schema kinds. This handles generic peer types (e.g., LocationHosting) where the concrete kind (LocationBuilding) differs from the relationship declaration. Lookup order for relationship values: 1. UUID if it looks like one 2. Direct lookup on the declared peer kind (default_filter, then HFID) 3. Search all node schemas by default_filter and HFID
Only catch lookup-miss errors (NodeNotFoundError, SchemaNotFoundError, ValueError, IndexError) before falling back to generic peer search. Auth, network, and other unexpected errors now propagate instead of being silently swallowed.
asyncio_mode=auto in pyproject.toml already detects async tests. The anyio markers caused each test to run under both asyncio and trio, doubling the count unnecessarily.
Values like '00123' are now kept as strings instead of being coerced to int 123. The coercion only applies when str(int(v)) == v, ensuring no data loss for zip codes, serial numbers, rack unit names, etc.
Prevents AttributeError when non-NodeSchemaAPI entries lack a .kind attribute by narrowing to NodeSchemaAPI instances first.
feat: add CRUD and schema discovery commands to infrahubctl
Deploying infrahub-sdk-python with
|
| Latest commit: |
a9a6893
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2736d674.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://develop.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## infrahub-develop #914 +/- ##
====================================================
+ Coverage 81.09% 82.56% +1.46%
====================================================
Files 121 134 +13
Lines 10592 13190 +2598
Branches 1581 2286 +705
====================================================
+ Hits 8590 10890 +2300
- Misses 1487 1652 +165
- Partials 515 648 +133
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 14 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Resolves merge conflict with infrahub-develop where specs is a symlink to dev/specs. Moves spec files to dev/specs/ and creates the symlink so both branches agree on the structure.
The symlink from specs/ -> dev/specs/ was redundant. Remove it and update all path references in templates, scripts, and spec documents to use dev/specs/ directly.
move specs/ to dev/specs/
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.
Merging develop into infrahub-develop after merging pull request #900.