Skip to content

Commit 6634745

Browse files
committed
feat(vendir): support extracting HTTP sources
As noted in #41435, Vendir's support for HTTP sources would be useful for Renovate to keep updated. Instead of managing the updating of files ourselves, we can use Vendir's existing `lockFileMaintenance` task to do so, where `vendir sync` will re-fetch the remote file(s) and sync them to the repo. For this to be supported, we can extract the HTTP sources with `unsupported-datasource`, so Renovate knows that the dependency is there, but can't be managed by us. This makes it possible to extract HTTP dependencies, and then have Renovate update them through `lockFileMaintenance`.
1 parent fdd1612 commit 6634745

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

lib/modules/manager/vendir/__fixtures__/valid-contents.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ directories:
4141
githubRelease:
4242
slug: test/test
4343
tag: "7.10.1"
44+
- path: openapi
45+
http:
46+
url: https://raw.githubusercontent.com/mend/renovate-ce-ee/refs/heads/main/docs/openapi-community.yaml

lib/modules/manager/vendir/extract.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ describe('modules/manager/vendir/extract', () => {
8484
packageName: 'test/test',
8585
datasource: 'github-releases',
8686
},
87+
{
88+
currentValue: 'latest',
89+
packageName:
90+
'https://raw.githubusercontent.com/mend/renovate-ce-ee/refs/heads/main/docs/openapi-community.yaml',
91+
depType: 'HttpSource',
92+
skipReason: 'unsupported-datasource',
93+
},
8794
],
8895
});
8996
// git-refs datasource does not support custom registries

lib/modules/manager/vendir/extract.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
GitRefDefinition,
1616
GithubReleaseDefinition,
1717
HelmChartDefinition,
18+
HttpReleaseDefinition,
1819
VendirDefinition,
1920
} from './schema.ts';
2021
import { Vendir } from './schema.ts';
@@ -71,6 +72,17 @@ export function extractGithubReleaseSource(
7172
};
7273
}
7374

75+
export function extractHttpReleaseSource(
76+
httpRelease: HttpReleaseDefinition,
77+
): PackageDependency {
78+
return {
79+
packageName: httpRelease.url,
80+
currentValue: 'latest',
81+
depType: 'HttpSource',
82+
skipReason: 'unsupported-datasource',
83+
};
84+
}
85+
7486
export function parseVendir(
7587
content: string,
7688
packageFile?: string,
@@ -111,6 +123,9 @@ export function extractPackageFile(
111123
} else if ('githubRelease' in content && content.githubRelease) {
112124
const dep = extractGithubReleaseSource(content.githubRelease);
113125
deps.push(dep);
126+
} else if ('http' in content && content.http) {
127+
const dep = extractHttpReleaseSource(content.http);
128+
deps.push(dep);
114129
}
115130
}
116131

lib/modules/manager/vendir/readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,22 @@ directories:
8080
# optional if tagSelection is specified (available in v0.22.0+)
8181
tag: v0.1.0
8282
```
83+
84+
### HTTP
85+
86+
<!-- prettier-ignore -->
87+
!!! note
88+
Updates to dependencies tracked through the HTTP source can only be updated using [`lockFileMaintenance`](../../../configuration-options.md#lockfilemaintenance).
89+
90+
Renovate can extract HTTP dependency sources, but will not update them without [`lockFileMaintenance`](../../../configuration-options.md#lockfilemaintenance).
91+
92+
```yaml title="Example vendir.yml for syncing a remote file"
93+
apiVersion: vendir.k14s.io/v1alpha1
94+
kind: Config
95+
directories:
96+
- path: internal
97+
contents:
98+
- path: renovate-ce
99+
http:
100+
url: https://raw.githubusercontent.com/mend/renovate-ce-ee/refs/main/docs/openapi-community.yaml
101+
```

lib/modules/manager/vendir/schema.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,20 @@ export const GithubReleaseContent = z.object({
4141
githubRelease: GithubRelease,
4242
});
4343

44+
export const HttpRelease = z.object({
45+
url: z.string(),
46+
});
47+
48+
export const HttpContent = z.object({
49+
path: z.string(),
50+
http: HttpRelease,
51+
});
52+
4453
export const Contents = z.union([
4554
HelmChartContent,
4655
GitRefContent,
4756
GithubReleaseContent,
57+
HttpContent,
4858
]);
4959

5060
export const Vendir = VendirResource.extend({
@@ -60,3 +70,4 @@ export type VendirDefinition = z.infer<typeof Vendir>;
6070
export type HelmChartDefinition = z.infer<typeof HelmChart>;
6171
export type GitRefDefinition = z.infer<typeof GitRef>;
6272
export type GithubReleaseDefinition = z.infer<typeof GithubRelease>;
73+
export type HttpReleaseDefinition = z.infer<typeof HttpRelease>;

0 commit comments

Comments
 (0)