Skip to content

Conversation

@JAVGan
Copy link
Contributor

@JAVGan JAVGan commented Jul 31, 2025

This commit changes the git_utils.py to receive the index image to git URL mapping as a parameter, since this value isn't stored on IIB workers config.

It also adjusts the methods handle_[add|rm]_request from build.py to pass the index to git url mappings as parameter for the lower functions.

Refers to CLOUDDST-28805

Summary by Sourcery

Fix git_utils to accept the index image-to-Git URL mapping as an explicit parameter and propagate this mapping through the build task functions, updating tests to match the new API.

Bug Fixes:

  • Use index image to Git URL mapping passed as a parameter instead of reading from worker config in git_utils

Enhancements:

  • Rename get_git_url to resolve_git_url and require an index_repo_map parameter
  • Propagate the index_repo_map argument through push_configs_to_git, revert_last_commit, and the build task functions (_update_index_image_pull_spec, _overwrite_from_index, handle_add_request, handle_rm_request)

Tests:

  • Update tests to supply the new git URL mapping fixture and reference resolve_git_url instead of get_git_url

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 31, 2025

Reviewer's Guide

Refactor git_utils to accept index-to-git URL mappings via parameters instead of worker config, propagate this mapping through build tasks, and update tests accordingly.

Flow diagram for passing index_repo_map through build to git_utils

flowchart TD
    A[handle_add_request / handle_rm_request] --> B[_update_index_image_pull_spec]
    B --> C[_overwrite_from_index]
    C --> D[push_configs_to_git]
    C --> E[revert_last_commit]
    D --> F[resolve_git_url]
    E --> F
    subgraph "Parameter propagation"
      A -- index_repo_map --> B
      B -- index_repo_map --> C
      C -- index_repo_map --> D
      C -- index_repo_map --> E
      D -- index_repo_map --> F
      E -- index_repo_map --> F
    end
Loading

File-Level Changes

Change Details Files
Introduce resolve_git_url with external mapping parameter
  • Rename get_git_url to resolve_git_url and add index_repo_map argument
  • Remove internal worker config lookup for URL mapping
  • Update push_configs_to_git and revert_last_commit to use resolve_git_url with passed mapping
iib/workers/tasks/git_utils.py
Propagate index_repo_map through build task functions
  • Add index_repo_map parameter to _update_index_image_pull_spec and _overwrite_from_index
  • Modify handle_add_request and handle_rm_request to pass index_repo_map
  • Pass mapping through internal calls when is_image_fbc is true
iib/workers/tasks/build.py
Adjust tests for new mapping parameter
  • Add gitlab_url_mapping fixture and remove mapping from get_worker_config mock
  • Update import and test names: get_git_url → resolve_git_url
  • Inject index_repo_map into test calls in test_build
tests/test_workers/test_tasks/test_git_utils.py
tests/test_workers/test_tasks/test_build.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JAVGan - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `iib/workers/tasks/build.py:258` </location>
<code_context>
     resolved_prebuild_from_index: Optional[str] = None,
     add_or_rm: bool = False,
     is_image_fbc: bool = False,
+    index_repo_map: Dict[str, str] = {},
 ) -> None:
     """
</code_context>

<issue_to_address>
Avoid using a mutable default argument for index_repo_map.

Use None as the default value and initialize the dict within the function to prevent shared state across calls.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JAVGan JAVGan force-pushed the fix_git_url_map branch from 5dff60a to 3a8c968 Compare July 31, 2025 21:36
This commit changes the `git_utils.py` to receive the index image to git
URL mapping as a parameter, since this value isn't stored on IIB workers
config.

It also adjusts the methods `handle_[add|rm]_request` from `build.py` to
pass the index to git url mappings as parameter for the lower functions.

Refers to CLOUDDST-28805

Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
@JAVGan JAVGan force-pushed the fix_git_url_map branch from 3a8c968 to a334c2b Compare July 31, 2025 21:38
@JAVGan JAVGan merged commit 03ebadb into master Jul 31, 2025
2 checks passed
@JAVGan JAVGan deleted the fix_git_url_map branch July 31, 2025 21:48
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