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: replacement support for more autoreplace managers #17476

Closed
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function mergeChildConfig<
if (
option.mergeable &&
childConfig[option.name] &&
parentConfig[option.name]
parentConfig[option.name] &&
parentConfig[option.name] !== childConfig[option.name]
Copy link
Member

Choose a reason for hiding this comment

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

why this change? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this I had the problem that my newName, newValue and finally depName changed from one string to an array of single characters.

) {
logger.trace(`mergeable option: ${option.name}`);
if (option.name === 'constraints') {
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ function getDigestConfig(
config: GetDigestInputConfig
): DigestConfig {
const { currentValue, currentDigest } = config;
const packageName = config.packageName ?? config.depName;
const packageName =
config.replacementName ?? config.packageName ?? config.depName;
Comment on lines +436 to +437
Copy link
Member

Choose a reason for hiding this comment

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

why this change?

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 "packageName" is used to look up digests. After this change it is able to replace images with digests, as now the correct digest for the replacement is used. Without this the depName would be replaced, but the old digest would be used as the old name would be used in lookUp

const [registryUrl] = resolveRegistryUrls(
datasource,
config.defaultRegistryUrls,
Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface GetDigestInputConfig {
additionalRegistryUrls?: string[];
currentValue?: string;
currentDigest?: string;
replacementName?: string;
}

export interface DigestConfig {
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/versioning/pep440/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function getNewValue({
rangeStrategy,
currentVersion,
newVersion,
isReplacement,
}: NewValueConfig): string | null {
let ranges: Range[];
let updatedRange: (string | null)[];
Expand All @@ -102,7 +103,7 @@ export function getNewValue({
}

// no symbol: accept only that specific version specified
if (currentValue === currentVersion) {
if (currentValue === currentVersion || isReplacement) {
return newVersion;
}

Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface NewValueConfig {
rangeStrategy: RangeStrategy;
currentVersion?: string;
newVersion: string;
isReplacement?: boolean;
}
export interface VersioningApi {
// validation
Expand Down
7 changes: 4 additions & 3 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ export async function lookupUpdates(
res.updates.push(rollback);
}
let rangeStrategy = getRangeStrategy(config);
if (dependency.replacementName && dependency.replacementVersion) {
if (config.replacementVersion && config.replacementName) {
res.updates.push({
updateType: 'replacement',
newName: dependency.replacementName,
newName: config.replacementName,
newValue: versioning.getNewValue({
// TODO #7154
currentValue: currentValue!,
newVersion: dependency.replacementVersion,
newVersion: config.replacementVersion,
rangeStrategy: rangeStrategy!,
isReplacement: true,
})!,
});
}
Expand Down
2 changes: 2 additions & 0 deletions lib/workers/repository/process/lookup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface LookupUpdateConfig
depName: string;
minimumConfidence?: string;
extractedConstraints?: Record<string, string>;
replacementVersion?: string;
replacementName?: string;
}

export interface UpdateResult {
Expand Down
Loading