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: regex manager #5617

Merged
merged 20 commits into from
Mar 6, 2020
Merged

feat: regex manager #5617

merged 20 commits into from
Mar 6, 2020

Conversation

rarkins
Copy link
Collaborator

@rarkins rarkins commented Mar 2, 2020

Adds initial support for custom/generic/regex managers.

Closes #1938

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 2, 2020

  • customManagers: is this name ok? As opposed to regexManagers or genericManagers, etc
  • Naming of subfields. Initially I used depName, datasource, etc - but it caused some havoc with the autoReplacefunctionality so I added aTemplate` suffix to remove conflicts. The end result though is less elegant fields
  • Needs tests
  • Add some more documentation
  • Need to add config validation

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 2, 2020

Here is it in action with a Dockerfile based off this repo's: https://github.com/renovate-tests/custom2

lib/manager/index.ts Outdated Show resolved Hide resolved
@rarkins rarkins requested a review from viceice March 2, 2020 14:08
lib/config/validation.ts Outdated Show resolved Hide resolved
Comment on lines 29 to 37
export interface CustomExtractConfig extends ExtractConfig {
matchStrings: string[];
depNameTemplate?: string;
lookupNameTemplate?: string;
currentValueTemplate?: string;
datasourceTemplate?: string;
versioningTemplate?: string;
}

Copy link
Member

Choose a reason for hiding this comment

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

Can we reuse the CustomManager interface above? We can move it to the lib/types path.

Suggested change
export interface CustomExtractConfig extends ExtractConfig {
matchStrings: string[];
depNameTemplate?: string;
lookupNameTemplate?: string;
currentValueTemplate?: string;
datasourceTemplate?: string;
versioningTemplate?: string;
}
export type CustomExtractConfig = CustomManager & ExtractConfig;

@JamieMagee
Copy link
Contributor

No real comments on the code, looks fine. Maybe just some more explicit typing?

Naming is hard, but to me customManagers sounds like plugins, and I would lean towards regexManagers, but I don't feel strongly one way or the other.

Co-Authored-By: Michael Kriese <michael.kriese@visualon.de>
@ppmathis
Copy link
Contributor

ppmathis commented Mar 2, 2020

Code looks fine to me as well. As previously discussed on Slack, I think this is a great feature which has a lot of potential for using Renovate to manage dependencies in very specific situations.

Can't really decide on a name and I think both customManagers as well as regexManagers are viable. As an alternative, I could also imagine patternManagers if regex shouldn't be specifically mentioned for some reason while still avoiding the risk of getting it mixed up with plugins as mentioned by Jamie.

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

patternManagers sounds good.

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 2, 2020

I'm leaning towards regexManagers. Pros:

  • Consistent naming with our 'regex' versioning scheme
  • The name helps describe what it does, while "custom" does not. If in future we worked out a superior non-regex way to achieve the same, we could always rename it then anyway

I think no matter what we call it, there will be some confusion about whether it's "managing regexes" rather than being a "regex-based manager". I don't like patternManagers at first glance - will think about it.

Also, I'm not sure why associating the name with "plugins" is a bad thing? In a way I think it sort of is like supporting manager plugins - just that they're regex-based.

BTW renaming and migrating later if we change our mind isn't too hard to do anyway.

@rarkins rarkins changed the title feat: customManagers feat: regex manager Mar 3, 2020
@rarkins
Copy link
Collaborator Author

rarkins commented Mar 3, 2020

I think I'll leaving typing as-is for now but feel free to refactor it later. Any objections to merging?

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

LGTM

@rarkins rarkins merged commit b2b8d7e into master Mar 6, 2020
@rarkins rarkins deleted the feat/1938-custom-manager branch March 6, 2020 08:07
@felixfbecker
Copy link

This is awesome!
The only thing I don't quite understand from the docs is datasource. How could I configure datasource so that it would pick up apk package versions?
For example, I imagine I could pluck the latest version for a package from http://nl.alpinelinux.org/alpine/edge/main/x86_64 with a regex

href="(?<packageName>)-(?<version>).apk"

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 6, 2020

@felixfbecker we’ll need to add an apk datasource first, then it should be feasible. We don’t yet have “regex datasources” too :)

@felixfbecker
Copy link

I see.

@felixfbecker
Copy link

I thought I could get by with using Node's GitHub release tags, but Alpine node releases are always also tagged with -r0 etc for new builds if e.g. openssh was updated and dependents need to be rebuilt. So that's not enough yet :(

Btw, is there an official JSON schema I can use to get autocompletion while trying this out? The one in JSONSchemaStore is missing a lot of config by now

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 6, 2020

Yes, we updated our official schema to point to docs.renovatebot.com/renovate-schema.json and it’s automatically built from master using submodule updating (which you were also interested in). It might trail master by an hour or two most times

@felixfbecker
Copy link

Maybe JSON schema store could be configured to redirect to that, as many tools use it as an API to auto-discover schemas :)

@felixfbecker
Copy link

Oh, just noticed that was already done 💯

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic version detection/replacement
5 participants