Skip to content

Move object commands into own package#935

Merged
gmazoyer merged 2 commits intodevelopfrom
gma-20260409-refactor-object-module
Apr 10, 2026
Merged

Move object commands into own package#935
gmazoyer merged 2 commits intodevelopfrom
gma-20260409-refactor-object-module

Conversation

@gmazoyer
Copy link
Copy Markdown
Contributor

@gmazoyer gmazoyer commented Apr 9, 2026

Why & What

The CRUD command files (create, delete, get, update) and their shared utilities lived in a generic "commands" directory that didn't convey what they were for. Since they all belong to the "infrahubctl object" subgroup, it makes sense to colocate them as an "object" package.

Test files follow the same restructuring.

Checklist

  • Tests added/updated
  • Changelog entry added (uv run towncrier create ...)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)

Summary by CodeRabbit

  • Documentation
    • Updated CLI architecture documentation to reflect new organization of subcommand groups.

The CRUD command files (create, delete, get, update) and their shared
utilities lived in a generic "commands" directory that didn't convey
what they were for. Since they all belong to the "infrahubctl object"
subgroup, it makes sense to colocate them as an "object" package.

Test files follow the same restructuring.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Walkthrough

This pull request refactors the CLI architecture from a centralized commands/ directory structure to a package-based organization. The object command group is converted to a package with individual command implementations in separate files (create.py, delete.py, get.py, update.py) and shared utilities in utils.py, coordinated through __init__.py. Import paths throughout the codebase are updated from infrahub_sdk.ctl.commands.* to infrahub_sdk.ctl.object.*. Documentation is updated to reflect this new organizational pattern. Tests are modified to patch functions at their new import locations.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main refactoring change: moving object-related command files from a generic 'commands' directory into their own 'object' package for better code organization.
Description check ✅ Passed The pull request description covers the essential information: the 'Why' section explains the rationale for the restructuring, the 'What' section describes the relocation of CRUD command files and utilities, and the author indicates which checklist items were completed (internal docs updated). However, it is missing the 'How to review' and 'How to test' sections from the template, and several checklist items remain unchecked without explanation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

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

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40aa0a3
Status: ✅  Deploy successful!
Preview URL: https://d4f39c73.infrahub-sdk-python.pages.dev
Branch Preview URL: https://gma-20260409-refactor-object.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #935      +/-   ##
===========================================
+ Coverage    75.59%   81.10%   +5.50%     
===========================================
  Files          134      131       -3     
  Lines        13252    10918    -2334     
  Branches      2306     1653     -653     
===========================================
- Hits         10018     8855    -1163     
+ Misses        2585     1514    -1071     
+ Partials       649      549     -100     
Flag Coverage Δ
integration-tests 42.95% <100.00%> (?)
python-3.10 53.70% <100.00%> (-3.04%) ⬇️
python-3.11 53.71% <100.00%> (-3.02%) ⬇️
python-3.12 53.70% <100.00%> (-3.04%) ⬇️
python-3.13 53.70% <100.00%> (-3.04%) ⬇️
python-3.14 55.31% <100.00%> (-3.28%) ⬇️
python-filler-3.12 22.76% <0.00%> (-0.16%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/ctl/object/__init__.py 44.44% <100.00%> (ø)
infrahub_sdk/ctl/object/create.py 92.00% <100.00%> (ø)
infrahub_sdk/ctl/object/delete.py 100.00% <100.00%> (ø)
infrahub_sdk/ctl/object/get.py 86.48% <100.00%> (ø)
infrahub_sdk/ctl/object/update.py 75.78% <100.00%> (ø)
infrahub_sdk/ctl/object/utils.py 98.14% <ø> (ø)

... and 44 files with indirect coverage changes

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

@gmazoyer gmazoyer marked this pull request as ready for review April 10, 2026 07:27
@gmazoyer gmazoyer requested a review from a team as a code owner April 10, 2026 07:27
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
dev/knowledge/cli-architecture.md (1)

24-24: Optional wording polish for sentence repetition.

Line 24 starts with “For …” in a sequence that reads slightly repetitive; a small rephrase would improve flow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dev/knowledge/cli-architecture.md` at line 24, Reword the sentence at line 24
to avoid starting with "For" after the previous sentence; e.g., rephrase the
phrase that mentions subcommands and where to place them so it reads smoothly
while preserving the examples "infrahub_sdk/ctl/object/" and "__init__.py"
(object subcommands live in that package and are registered on the object app in
__init__.py). Ensure the meaning stays identical but change the sentence
structure to reduce repetition and improve flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dev/knowledge/cli-architecture.md`:
- Line 24: Reword the sentence at line 24 to avoid starting with "For" after the
previous sentence; e.g., rephrase the phrase that mentions subcommands and where
to place them so it reads smoothly while preserving the examples
"infrahub_sdk/ctl/object/" and "__init__.py" (object subcommands live in that
package and are registered on the object app in __init__.py). Ensure the meaning
stays identical but change the sentence structure to reduce repetition and
improve flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b8ff3d26-d833-4123-8951-603f75cc3d8b

📥 Commits

Reviewing files that changed from the base of the PR and between 91d7c77 and 40aa0a3.

📒 Files selected for processing (16)
  • dev/knowledge/cli-architecture.md
  • infrahub_sdk/ctl/commands/__init__.py
  • infrahub_sdk/ctl/object/__init__.py
  • infrahub_sdk/ctl/object/create.py
  • infrahub_sdk/ctl/object/delete.py
  • infrahub_sdk/ctl/object/get.py
  • infrahub_sdk/ctl/object/update.py
  • infrahub_sdk/ctl/object/utils.py
  • tests/unit/ctl/object/__init__.py
  • tests/unit/ctl/object/test_create.py
  • tests/unit/ctl/object/test_delete.py
  • tests/unit/ctl/object/test_get.py
  • tests/unit/ctl/object/test_update.py
  • tests/unit/ctl/object/test_utils.py
  • tests/unit/ctl/schema/__init__.py
  • tests/unit/ctl/schema/test_schema.py
💤 Files with no reviewable changes (1)
  • infrahub_sdk/ctl/commands/init.py

Comment on lines -1 to -3
"""Command modules for the ``infrahub`` end-user CLI."""

from __future__ import annotations
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gmazoyer gmazoyer merged commit 729e8ef into develop Apr 10, 2026
21 checks passed
@gmazoyer gmazoyer deleted the gma-20260409-refactor-object-module branch April 10, 2026 19:26
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.

2 participants