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(vendir): add support for github releases #28175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/modules/manager/vendir/__fixtures__/valid-contents.yaml
Expand Up @@ -36,3 +36,8 @@ directories:
git:
url: https://github.com/test/test
ref: "7.10.1"
# Normal GithubRelease Repo
- path: custom-repo-custom-version
githubRelease:
slug: test/test
tag: "7.10.1"
6 changes: 6 additions & 0 deletions lib/modules/manager/vendir/extract.spec.ts
Expand Up @@ -78,6 +78,12 @@ describe('modules/manager/vendir/extract', () => {
packageName: 'https://github.com/test/test',
datasource: 'git-refs',
},
{
currentValue: '7.10.1',
depName: 'test/test',
packageName: 'test/test',
datasource: 'github-releases',
},
],
});
});
Expand Down
22 changes: 19 additions & 3 deletions lib/modules/manager/vendir/extract.ts
Expand Up @@ -2,6 +2,7 @@ import { logger } from '../../../logger';
import { getHttpUrl } from '../../../util/git/url';
import { parseSingleYaml } from '../../../util/yaml';
import { GitRefsDatasource } from '../../datasource/git-refs';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { HelmDatasource } from '../../datasource/helm';
import { getDep } from '../dockerfile/extract';
import { isOCIRegistry } from '../helmv3/utils';
Expand All @@ -12,14 +13,12 @@ import type {
} from '../types';
import {
GitRefDefinition,
GithubReleaseDefinition,
HelmChartDefinition,
Vendir,
VendirDefinition,
} from './schema';

// TODO: Add support for other vendir types (like git tags, github releases, etc.)
// Recommend looking at the kustomize manager for more information on support.

export function extractHelmChart(
helmChart: HelmChartDefinition,
aliases?: Record<string, string> | undefined,
Expand Down Expand Up @@ -63,6 +62,18 @@ export function extractGitSource(
};
}

export function extractGithubReleaseSource(
githubRelease: GithubReleaseDefinition,
): PackageDependency | null {
return {
depName: githubRelease.slug,
packageName: githubRelease.slug,
depType: 'GithubRelease',
currentValue: githubRelease.tag,
datasource: GithubReleasesDatasource.id,
};
}

export function parseVendir(
content: string,
packageFile?: string,
Expand Down Expand Up @@ -104,6 +115,11 @@ export function extractPackageFile(
if (dep) {
deps.push(dep);
}
} else if ('githubRelease' in content && content.githubRelease) {
const dep = extractGithubReleaseSource(content.githubRelease);
if (dep) {
deps.push(dep);
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions lib/modules/manager/vendir/readme.md
Expand Up @@ -58,3 +58,20 @@ directories:
depth: 1
...
```

### GithubRelease

Renovates supporting explicit tags in for github releases in vendir.yml

```yaml title="Example github vendir.yml"
directories:
- path: config/_ytt_lib
contents:
path: github.com/cloudfoundry/cf-k8s-networking
githubRelease:
# slug for repository (org/repo) (required)
slug: k14s/kapp-controller
# use release tag (optional)
# optional if tagSelection is specified (available in v0.22.0+)
tag: v0.1.0
```
17 changes: 16 additions & 1 deletion lib/modules/manager/vendir/schema.ts
Expand Up @@ -12,6 +12,11 @@ export const GitRef = z.object({
depth: z.number().optional(),
});

export const GithubRelease = z.object({
slug: z.string(),
tag: z.string(),
});

export const HelmChart = z.object({
name: z.string(),
version: z.string(),
Expand All @@ -30,7 +35,16 @@ export const GitRefContent = z.object({
git: GitRef,
});

export const Contents = z.union([HelmChartContent, GitRefContent]);
export const GithubReleaseContent = z.object({
path: z.string(),
githubRelease: GithubRelease,
});

export const Contents = z.union([
HelmChartContent,
GitRefContent,
GithubReleaseContent,
]);

export const Vendir = VendirResource.extend({
directories: z.array(
Expand All @@ -44,3 +58,4 @@ export const Vendir = VendirResource.extend({
export type VendirDefinition = z.infer<typeof Vendir>;
export type HelmChartDefinition = z.infer<typeof HelmChart>;
export type GitRefDefinition = z.infer<typeof GitRef>;
export type GithubReleaseDefinition = z.infer<typeof GithubRelease>;