Skip to content

Commit

Permalink
feat(go): Add support for Go host code.cloudfoundry.org
Browse files Browse the repository at this point in the history
## Changes

Dependency updates for Go libraries from `code.cloudfoundry.org` are now supported.

## Context

In renovatebot#18246 it was discussed that the error message
```
Unsupported go host - cannot look up versions
```

is not a bug when using Go dependencies from `code.cloudfoundry.org`,
however in our daily work on `app-autoscaler-release` it is unfortunate
[such dependencies are not automatically updated by Renovate](cloudfoundry/app-autoscaler-release#1100)

## Documentation (please check one with an [x])

- [ ] I have updated the documentation, or
- [x] 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
- [x] Both unit tests + ran on a real repository
  • Loading branch information
silvestre committed Oct 12, 2023
1 parent f277ab7 commit 38e3623
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/modules/datasource/go/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ const hostRules = mocked(_hostRules);
describe('modules/datasource/go/base', () => {
describe('simple cases', () => {
it.each`
module | datasource | packageName
${'gopkg.in/foo'} | ${'github-tags'} | ${'go-foo/foo'}
${'gopkg.in/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
${'github.com/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
${'bitbucket.org/foo/bar'} | ${'bitbucket-tags'} | ${'foo/bar'}
module | datasource | packageName
${'gopkg.in/foo'} | ${'github-tags'} | ${'go-foo/foo'}
${'gopkg.in/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
${'github.com/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
${'bitbucket.org/foo/bar'} | ${'bitbucket-tags'} | ${'foo/bar'}
${'code.cloudfoundry.org/lager'} | ${'github-tags'} | ${'cloudfoundry/lager'}
`(
'$module -> $datasource: $packageName',
async ({ module, datasource, packageName }) => {
Expand Down
10 changes: 10 additions & 0 deletions lib/modules/datasource/go/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export class BaseGoDatasource {
};
}

if (goModule.startsWith('code.cloudfoundry.org/')) {
const split = goModule.split('/');
const packageName = 'cloudfoundry/' + split[1];
return {
datasource: GithubTagsDatasource.id,
packageName,
registryUrl: 'https://github.com',
};
}

return await BaseGoDatasource.goGetDatasource(goModule);
}

Expand Down

0 comments on commit 38e3623

Please sign in to comment.