Skip to content

Merge develop into infrahub-develop#914

Merged
ajtmccarty merged 42 commits intoinfrahub-developfrom
develop
Apr 3, 2026
Merged

Merge develop into infrahub-develop#914
ajtmccarty merged 42 commits intoinfrahub-developfrom
develop

Conversation

@infrahub-github-bot-app
Copy link
Copy Markdown
Contributor

Merging develop into infrahub-develop after merging pull request #900.

…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.
petercrocker and others added 9 commits March 28, 2026 23:05
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 3, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 88.92617% with 66 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/commands/update.py 75.53% 15 Missing and 8 partials ⚠️
infrahub_sdk/ctl/formatters/csv.py 79.54% 6 Missing and 3 partials ⚠️
infrahub_sdk/ctl/formatters/base.py 82.22% 5 Missing and 3 partials ⚠️
infrahub_sdk/ctl/formatters/table.py 85.10% 5 Missing and 2 partials ⚠️
infrahub_sdk/ctl/formatters/yaml.py 87.75% 3 Missing and 3 partials ⚠️
infrahub_sdk/ctl/commands/get.py 86.48% 3 Missing and 2 partials ⚠️
infrahub_sdk/ctl/parsers.py 92.85% 3 Missing and 1 partial ⚠️
infrahub_sdk/ctl/commands/create.py 93.87% 1 Missing and 2 partials ⚠️
infrahub_sdk/ctl/commands/utils.py 98.14% 0 Missing and 1 partial ⚠️
@@                 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     
Flag Coverage Δ
integration-tests 44.92% <63.25%> (+3.84%) ⬆️
python-3.10 56.63% <87.41%> (+3.97%) ⬆️
python-3.11 56.63% <87.41%> (+3.95%) ⬆️
python-3.12 56.63% <87.41%> (+3.97%) ⬆️
python-3.13 56.61% <87.41%> (+3.93%) ⬆️
python-3.14 58.49% <87.41%> (+4.13%) ⬆️
python-filler-3.12 22.64% <0.00%> (-1.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/cli_commands.py 73.02% <100.00%> (+1.13%) ⬆️
infrahub_sdk/ctl/commands/__init__.py 100.00% <100.00%> (ø)
infrahub_sdk/ctl/commands/delete.py 100.00% <100.00%> (ø)
infrahub_sdk/ctl/formatters/__init__.py 100.00% <100.00%> (ø)
infrahub_sdk/ctl/formatters/json.py 100.00% <100.00%> (ø)
infrahub_sdk/ctl/schema.py 61.72% <100.00%> (+11.41%) ⬆️
infrahub_sdk/ctl/commands/utils.py 98.14% <98.14%> (ø)
infrahub_sdk/ctl/commands/create.py 93.87% <93.87%> (ø)
infrahub_sdk/ctl/parsers.py 92.85% <92.85%> (ø)
infrahub_sdk/ctl/commands/get.py 86.48% <86.48%> (ø)
... and 5 more

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Apr 3, 2026
@ajtmccarty ajtmccarty merged commit aa01aa6 into infrahub-develop Apr 3, 2026
51 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants