Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager/copier): propagate Git auth env vars #31931

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

GreyTeardrop
Copy link
Contributor

@GreyTeardrop GreyTeardrop commented Oct 13, 2024

Changes

Propagate Git authentication variables to calls for the copier CLI.

Context

At the moment, Copier isn't able to update from templates hosted in private repositories. Renovate properly detects those updates and creates update PRs but when copier is executed to apply the update it makes its own git calls and fails to authenticate with private Git repos, resulting in a failure

failure log
Command failed: copier update --skip-answered --defaults --answers-file .copier-answers.yml --vcs-ref v1.0.5
Traceback (most recent call last):
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
             ~~~~~~~~~~~~~~^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/cli/application.py", line 640, in run
    inst, retcode = subapp.run(argv, exit=False)
                    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/cli/application.py", line 635, in run
    retcode = inst.main(*tailargs)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/cli.py", line 425, in main
    return _handle_exceptions(inner)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
    ~~~~~~^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/cli.py", line 415, in inner
    with self._worker(
         ~~~~~~~~~~~~^
        dst_path=destination_path,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        overwrite=True,
        ^^^^^^^^^^^^^^^
    ) as worker:
    ^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/main.py", line 228, in __exit__
    raise value
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/cli.py", line 423, in inner
    worker.run_update()
    ~~~~~~~~~~~~~~~~~^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/main.py", line 857, in run_update
    self._check_unsafe("update")
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/main.py", line 242, in _check_unsafe
    if self.template.jinja_extensions:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/python/3.13.0/lib/python3.13/functools.py", line 1037, in __get__
    val = self.func(instance)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/template.py", line 338, in jinja_extensions
    return tuple(self.config_data.get("jinja_extensions", ()))
                 ^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/python/3.13.0/lib/python3.13/functools.py", line 1037, in __get__
    val = self.func(instance)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/template.py", line 300, in config_data
    result = filter_config(self._raw_config)[0]
                           ^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/python/3.13.0/lib/python3.13/functools.py", line 1037, in __get__
    val = self.func(instance)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/template.py", line 257, in _raw_config
    for p in self.local_abspath.glob("copier.*")
             ^^^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/python/3.13.0/lib/python3.13/functools.py", line 1037, in __get__
    val = self.func(instance)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/template.py", line 556, in local_abspath
    result = Path(clone(self.url_expanded, self.ref))
                  ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/copier/vcs.py", line 182, in clone
    _clone()
    ~~~~~~^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/commands/base.py", line 115, in __call__
    return self.run(args, **kwargs)[1]
           ~~~~~~~~^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/commands/base.py", line 254, in run
    return p.run()
           ~~~~~^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/commands/base.py", line 217, in runner
    return run_proc(p, retcode, timeout)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/commands/processes.py", line 330, in run_proc
    return _check_process(proc, retcode, timeout, stdout, stderr)
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/commands/processes.py", line 19, in _check_process
    proc.verify(retcode, timeout, stdout, stderr)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/containerbase/tools/copier/9.3.1/3.13.0/lib/python3.13/site-packages/plumbum/machines/base.py", line 29, in verify
    raise ProcessExecutionError(
        getattr(self, "argv", None), self.returncode, stdout, stderr
    )
plumbum.commands.processes.ProcessExecutionError: Unexpected exit code: 128
Command line: | /usr/bin/git clone --no-checkout https://github.com/GreyTeardrop/private-copier-template.git /tmp/copier.vcs.clone.z922swsv --filter=blob:none
Stderr:       | Cloning into '/tmp/copier.vcs.clone.z922swsv'...
              | fatal: could not read Username for 'https://github.com': No such device or address

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

The https://github.com/GreyTeardrop/copier-renovate-experiment repo contains test results - GreyTeardrop/copier-renovate-experiment#7 as created by stock Renovate GitHub app and GreyTeardrop/copier-renovate-experiment#6 as created by Renovate with this patch.

@GreyTeardrop GreyTeardrop changed the title feat(manager/copier) propagate Git auth env vars feat(manager/copier): propagate Git auth env vars Oct 13, 2024
@rarkins rarkins added this pull request to the merge queue Oct 14, 2024
Merged via the queue into renovatebot:main with commit 5cb1078 Oct 14, 2024
39 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 38.121.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

zemnmez-renovate-bot added a commit to zemn-me/monorepo that referenced this pull request Oct 14, 2024
##### v38.121.0 

##### Features

-   **manager/copier:** propagate Git auth env vars ([#31931](renovatebot/renovate#31931)) ([5cb1078](renovatebot/renovate@5cb1078))

##### Documentation

-   update references to renovate/renovate ([#31936](renovatebot/renovate#31936)) ([9034b43](renovatebot/renovate@9034b43))

##### Miscellaneous Chores

-   **deps:** lock file maintenance ([#31937](renovatebot/renovate#31937)) ([d6250d1](renovatebot/renovate@d6250d1))
-   **deps:** update containerbase/internal-tools action to v3.4.30 ([#31935](renovatebot/renovate#31935)) ([6babf2d](renovatebot/renovate@6babf2d))
-   **docs:** remove duplicate sentence ([#31757](renovatebot/renovate#31757)) ([9bd101c](renovatebot/renovate@9bd101c))
@GreyTeardrop GreyTeardrop deleted the feat/copier-git-auth branch October 14, 2024 08:40
github-merge-queue bot pushed a commit to zemn-me/monorepo that referenced this pull request Oct 14, 2024
##### v38.121.0 

##### Features

-   **manager/copier:** propagate Git auth env vars ([#31931](renovatebot/renovate#31931)) ([5cb1078](renovatebot/renovate@5cb1078))

##### Documentation

-   update references to renovate/renovate ([#31936](renovatebot/renovate#31936)) ([9034b43](renovatebot/renovate@9034b43))

##### Miscellaneous Chores

-   **deps:** lock file maintenance ([#31937](renovatebot/renovate#31937)) ([d6250d1](renovatebot/renovate@d6250d1))
-   **deps:** update containerbase/internal-tools action to v3.4.30 ([#31935](renovatebot/renovate#31935)) ([6babf2d](renovatebot/renovate@6babf2d))
-   **docs:** remove duplicate sentence ([#31757](renovatebot/renovate#31757)) ([9bd101c](renovatebot/renovate@9bd101c))
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.

3 participants