Skip to content

Clean up logic to load repository config items#866

Merged
ogenstad merged 2 commits intoinfrahub-developfrom
pog-repository-loading
Mar 17, 2026
Merged

Clean up logic to load repository config items#866
ogenstad merged 2 commits intoinfrahub-developfrom
pog-repository-loading

Conversation

@ogenstad
Copy link
Copy Markdown
Contributor

@ogenstad ogenstad commented Mar 13, 2026

Why

  • Clean up code to load different sections from a .infrahub.yml file
  • The reason is that the extra layer we have now doesn't provide much value and only makes these simple calls more complex.

What changed

  • Removed TypeVar from the imports
  • Removed ResourceClass = TypeVar("ResourceClass")
  • Removed RESOURCE_MAP dict
  • Removed _has_resource and _get_resource generic helper methods
  • Replaced all 12 public methods (has_* / get_*) with direct implementations that iterate typed fields (e.g. self.jinja2_transforms) and compare item.name directly, instead of routing through getattr and the map

Summary by CodeRabbit

Release Notes

  • Refactor

    • Removed internal type declarations and resource mapping utilities to streamline the schema repository implementation.
  • Tests

    • Added comprehensive unit test coverage for repository configuration, including validation of duplicate detection and resource retrieval functionality across all definition types.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55e44e3e-4246-40e7-beea-09201c7b1e43

📥 Commits

Reviewing files that changed from the base of the PR and between f737549 and 1ccef9b.

📒 Files selected for processing (2)
  • infrahub_sdk/schema/repository.py
  • tests/unit/sdk/test_schema_repository.py

Walkthrough

This change removes two public declarations (ResourceClass type alias and RESOURCE_MAP mapping) from the repository module. Concurrently, it introduces a comprehensive unit test suite for InfrahubRepositoryConfig, including a fixture and tests that validate duplicate name detection, presence checks (has_* methods), and retrieval operations (get_* methods) across six definition types: jinja2_transforms, check_definitions, artifact_definitions, python_transforms, generator_definitions, and queries. The test suite also verifies proper error handling when resources are not found.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: cleaning up the logic for loading repository config items by removing unnecessary abstractions.
Description check ✅ Passed The description covers the key sections: Why (problem and goal), What changed (specific implementation details), and addresses the core refactoring work without missing critical information.

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

📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop     #866      +/-   ##
====================================================
+ Coverage             80.64%   80.70%   +0.05%     
====================================================
  Files                   118      118              
  Lines                 10246    10255       +9     
  Branches               1534     1544      +10     
====================================================
+ Hits                   8263     8276      +13     
+ Misses                 1455     1452       -3     
+ Partials                528      527       -1     
Flag Coverage Δ
integration-tests 40.32% <16.12%> (-0.04%) ⬇️
python-3.10 51.93% <96.77%> (+0.11%) ⬆️
python-3.11 51.95% <96.77%> (+0.13%) ⬆️
python-3.12 51.93% <96.77%> (+0.11%) ⬆️
python-3.13 51.95% <96.77%> (+0.13%) ⬆️
python-3.14 53.64% <96.77%> (+0.12%) ⬆️
python-filler-3.12 23.96% <9.67%> (-0.07%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/schema/repository.py 89.10% <100.00%> (+2.02%) ⬆️

... and 1 file with indirect coverage changes

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

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

cloudflare-workers-and-pages Bot commented Mar 13, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1ccef9b
Status: ✅  Deploy successful!
Preview URL: https://a4983db7.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-repository-loading.infrahub-sdk-python.pages.dev

View logs

@ogenstad ogenstad marked this pull request as ready for review March 17, 2026 09:37
@ogenstad ogenstad requested a review from a team as a code owner March 17, 2026 09:37
@ogenstad ogenstad merged commit cce6014 into infrahub-develop Mar 17, 2026
21 checks passed
@ogenstad ogenstad deleted the pog-repository-loading branch March 17, 2026 16:03
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