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

hostRules: support dynamic username/password/token fields in config.js #31769

Open
rarkins opened this issue Oct 3, 2024 · 1 comment
Open
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@rarkins
Copy link
Collaborator

rarkins commented Oct 3, 2024

Describe the proposed change(s).

Some users have the need to use rotating credentials. We should enhance hostRules so that username, password and token fields can be a function, which Renovate awaits on before returning.

Example config.js after:

let githubToken;

async function getGitHubToken() {
  if (githubToken) {
    return githubToken;
  }
  githubToken = // some fetching logic;
  // delete cached token after 30 minutes
  setTimeout(() => {
    githubToken = undefined;
  }, 30*60*1000);

}

module.exports = {
  hostRules: [{
	matchHost: 'github.com',
  }]
}

hostRules functions in lib/util/host-rules which can return credentials (such as find, findAll) should be modified to resolve such fields before returning them when they're a function like this. Such function will themselves now need to be awaitable.

Internally we should keep the HostRule type as having strings, but add a new InternalHostRule type we use for storage which allows strings or functions.

@rarkins rarkins added type:feature Feature (new functionality) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others labels Oct 3, 2024
@rarkins
Copy link
Collaborator Author

rarkins commented Oct 9, 2024

I experimented with implementing this but found that changing all hostRules find/get functions to async added a lot of complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

No branches or pull requests

1 participant