Skip to content

Conversation

@minitriga
Copy link
Contributor

@minitriga minitriga commented Apr 22, 2025

infrahubctl repository init /tmp/test will create a new repository with some basic structure to get started with Infrahub. It will prompt the user what they would like to include.

@github-actions github-actions bot added group/ci Issue related to the CI pipeline type/documentation Improvements or additions to documentation labels Apr 22, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 22, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3fb79ef
Status: ✅  Deploy successful!
Preview URL: https://7f37a203.infrahub-sdk-python.pages.dev
Branch Preview URL: https://atg-20250219-cs60.infrahub-sdk-python.pages.dev

View logs

@github-actions github-actions bot removed the group/ci Issue related to the CI pipeline label Apr 22, 2025
@github-actions github-actions bot added the group/ci Issue related to the CI pipeline label Apr 22, 2025
@github-actions github-actions bot removed the group/ci Issue related to the CI pipeline label Apr 22, 2025
@codecov
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/repository.py 63.15% 6 Missing and 1 partial ⚠️
@@             Coverage Diff             @@
##           develop     #371      +/-   ##
===========================================
- Coverage    73.91%   73.88%   -0.03%     
===========================================
  Files           92       92              
  Lines         8536     8555      +19     
  Branches      1676     1679       +3     
===========================================
+ Hits          6309     6321      +12     
- Misses        1781     1787       +6     
- Partials       446      447       +1     
Flag Coverage Δ
integration-tests 25.37% <0.00%> (-0.06%) ⬇️
python-3.10 47.39% <63.15%> (+0.05%) ⬆️
python-3.11 47.37% <63.15%> (+0.01%) ⬆️
python-3.12 47.37% <63.15%> (+0.01%) ⬆️
python-3.13 47.37% <63.15%> (+0.01%) ⬆️
python-3.9 45.79% <63.15%> (+0.01%) ⬆️
python-filler-3.12 24.20% <0.00%> (-0.06%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/ctl/repository.py 78.12% <63.15%> (-3.70%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@minitriga minitriga changed the title Infrahubctl Init command Infrahubctl repo Init command Apr 22, 2025

**Arguments**:

* `DST`: [required]
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear what DST is, or what it is that we are supposed to provide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should DST be optional? If not provided, we could make a directory from the project name that we prompt for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately from what I read copier requires the destination to be known upfront before the prompt appears using the run_copy function. By default copier will use cwd if nothing is passed in. which would require this workflow. We are using package name more for the pyproject.toml package name.

mkdir infrahub-repo`
cd infrahub-repo
infrahubctl repository init

Rather than just infrahubctl repository init infrahub-repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DST now also has help to explain what it is.


**Options**:

* `--data PATH`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, what is data in this case? A Path to a file? To what file? To a directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added helpers to the arguments for the docs to be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this options for the CLI command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what --data does allows user to pass in arguments via a file. Unfortunately defining options in two places I.E in the typer CLI and then in Copier prevents the copier prompts from appearing and will only use the CLI argument defaults. The idea of copier is that it remembers what the user selected previously so that repos can be updated in future where as the typer CLI does not.

@ogenstad
Copy link
Contributor

While I can see that this could be helpful for some people I think it would also be nice if we didn't have to add extra dependencies to the ctl. :)

Other solutions could potentially be to have some example repos that are easy to clone and use as a starting point.

Anyway some observations about this PR:

  • The tool can generate a "lib" folder, there's also an example of how this is used in combination with an "infrahubctl run" script. I don't think the same type of imports would work with a Transform, Check or Generator. I could be wrong on with that from lib.example import print_nodes, but if that's the case I think it might be confusing to include an example that would work with run but not the others
  • We're talking about migrating to uv, perhaps we'll want do do the same for these packages. It might be simple enough to change that after a migration though
  • I'd have "invoke" as a dev dependency instead of a main one
  • The use of Transforms or Generators would imply that Queries would be required, don't know if this can be done with copier?

@wvandeun
Copy link
Contributor

I would consider not loading the schema file. The recommendation is that when you manage the schema through the repository that you don't use infrahubctl schema for that purpose.

Some people find it very confusing that schema changes loaded using infrahubctl don't get synced into the schema files, when they use a normal external repository.

@minitriga minitriga closed this May 27, 2025
@BeArchiTek BeArchiTek deleted the atg-20250219-cs60 branch August 26, 2025 09:14
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.

4 participants