Skip to content

feat(containerbase): add packageRules support for containerbase dynamic install - #43635

Open
mistabanasik wants to merge 8 commits into
renovatebot:mainfrom
mistabanasik:feat/containerbase-tool-config-overrides
Open

mistabanasik wants to merge 8 commits into
renovatebot:mainfrom
mistabanasik:feat/containerbase-tool-config-overrides

Conversation

@mistabanasik

@mistabanasik mistabanasik commented May 27, 2026 •

Copy link
Copy Markdown

Changes

Renovate doesn't use packageRules when installing tools with containerbase, so for example changing repository url is not possible with binarySource=install.

This PR adds new option to instance global config, containerbasePackageRules which reuses packageRules for containerbase install-tool package resolutions.

Link to discussion:
#43636

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Yes, I've used AI tools to generate test cases.

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

Code was tested on corporate self-hosted repository.

@github-actions
github-actions Bot requested a review from viceice May 27, 2026 19:20
@jamietanna

Copy link
Copy Markdown
Member

I think we have some planned work around this @viceice, let's take a look and see how this proposal fits into it

@mistabanasik

Copy link
Copy Markdown
Author

Well now when I think of it, it might be better idea to reuse packageRules defined in global config.js. However if we add packageRules to GlobalConfig.OPTIONS they are removed from config passed to repository-level configuration in GlobalConfig.set. So we would have to add some kind of method like GlobalConfig.update so we can still pass packageRules down to repository-level config.

@mistabanasik

Copy link
Copy Markdown
Author

I've added another commit - we should use full config returned from applyPackageRules instead of picking only packageName, datasource, versioning and extractVersion fields. Thanks to that we can for example override registryUrl for node install-tool command, not only datasource.

@jamietanna jamietanna added the maintainer-input-needed Awaiting feedback from a maintainer label Jun 26, 2026
@mistabanasik

Copy link
Copy Markdown
Author

@jamietanna @viceice any thoughts on this PR?

@RahulGautamSingh RahulGautamSingh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

while we wait for maintainers review, could you please clean the pr title to not include the ...

@jamietanna
jamietanna marked this pull request as draft July 15, 2026 08:16
@jamietanna

Copy link
Copy Markdown
Member

Moving to draft until we get a chance to review the approach and work out if it matches where we want to go 👍🏼

@felipecrs

Copy link
Copy Markdown
Contributor

I didn't realize this PR (nor #43636 or #44608) and I proposed another PR that addresses the same issue:

Took a bit different approach, though.

@mistabanasik
mistabanasik marked this pull request as ready for review July 20, 2026 14:22
@github-actions
github-actions Bot requested a review from viceice July 20, 2026 14:22
@mistabanasik

mistabanasik commented Jul 20, 2026 •

Copy link
Copy Markdown
Author

I've changed my PR to rely purely on packageRules config without additional containerbasePackageRules. With new depType=tool-constraint we can also specifically address some packageRules to only target containerbase dynamic installs via matchDepTypes.

@jamietanna I saw your comment in the other thread - well this PR + containerbase URL replace env variables are sufficient to make containerbase dynamic install work with self-hosted package mirrors. I think in the future there should be a way without needing to set URL replace env variables, but for now in my opinion this PR is sufficient.

@mistabanasik mistabanasik changed the title feat(containerbase): add packageRules support for containerbase tool … feat(containerbase): add packageRules support for containerbase dynamic install Jul 20, 2026
@felipecrs

Copy link
Copy Markdown
Contributor

That's cool!

I closed my PR so there's one less to review.

Comment on lines +3025 to +3041
Package rules are also applied to tool installations when `binarySource=install` is used (containerbase dynamic installs).
Tools use `depType=tool-constraint`, so you can use `matchDepTypes: ["tool-constraint"]` to target them specifically.
For example, to override the Node.js tool datasource to a custom Artifactory registry:

```json
{
"packageRules": [
{
"matchDepNames": ["node"],
"matchDepTypes": ["tool-constraint"],
"overrideDatasource": "node-version",
"registryUrls": ["https://artifactory.example.com/nodejs"]
}
]
}
```

@felipecrs felipecrs Jul 20, 2026 •

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.

I believe repository-level packageRules will not be taken into account, and if so, I believe you should address this via documentation.

(and that's why I preferred to document in self-hosted configuration instead)

@viceice viceice left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this, and sorry for the long wait. I don't think this is the right layer, for these reasons:

  • Rule source: only the literal self-hosted packageRules passed to GlobalConfig.set are picked up. Rules from global extends presets, repositories[] entries, inherited config and repo config aren't included (see @felipecrs's open thread), so the docs promise more than the code does.
  • Leaks into tool installs: every matching admin rule now affects tool installs, not only rules targeting tool-constraint. For example, matchDatasources: ['github-releases'] with registryUrls, or matchDepNames: ['node'] with overrideDatasource, would silently change which tool versions get installed in existing setups.
  • Only half the problem: this only changes how the version is resolved. install-tool still downloads from containerbase's own URLs, so mirrors still need the URL-replace env vars, and a custom source can return versions containerbase can't install.

I'm working on a containerbase datasource (#46871), which resolves tool versions from containerbase's published version data and supports a mirror via registryUrls. I'd rather solve this with a dedicated admin setting for both the version mirror and the download mirror on top of that, instead of reusing packageRules here.

The branch also conflicts with recent containerbase.ts changes on main (#46587, #46580, #46823), so it needs a rebase either way.

Posted by Claude (Claude Code) on behalf of @viceice.

Comment thread lib/config/global.ts
delete result[option];
}

GlobalConfig.config.containerbasePackageRules = config.packageRules;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A side effect hidden in set() that captures only the literal self-hosted packageRules. Presets, repositories[] entries, inherited config and repo config are never included.

}

const { applyPackageRules } = await import('../package-rules/index.ts');
return applyPackageRules({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rules without matchDepTypes match here too. Most tools use github-releases, so a generic admin rule for that datasource (or for npm, node, …) now changes tool lookups. If this stays, it should be opt-in, limited to rules that explicitly target tool-constraint, and pass through only the fields that make sense for a tool lookup.

}

const { get: getVersioning } =
await import('../../modules/versioning/index.ts');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Constraint matching and the stable check still use the tool's default versioning, while the lookup uses the versioning from the rules. Apply the rules first, so both use the same versioning.

If multiple rules match a dependency, configurations from matching rules will be merged together.
The order of rules matters, because later rules may override configuration options from earlier ones, if they both specify the same option.

Package rules are also applied to tool installations when `binarySource=install` is used (containerbase dynamic installs).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Repo-level rules aren't applied, and this also runs in Docker mode, not only with binarySource=install. The downloads still need the URL-replace env vars as well.

@RahulGautamSingh RahulGautamSingh added the auto:inactive-pr PR has become inactive and we want to prompt the submitter label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there,

This PR appears to have been inactive for a while. Please let us know if you are still working on it, or if we can close it for now.

Thanks, the Renovate team

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audience:operator auto:inactive-pr PR has become inactive and we want to prompt the submitter bucket:workflow-fit maintainer-input-needed Awaiting feedback from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants