mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat(bazel): Support for rules_oci / oci_pull (#21216)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
9257f3ca2e
commit
480cff54ff
6 changed files with 82 additions and 1 deletions
|
@ -11,7 +11,7 @@ Renovate supports upgrading dependencies in Bazel `WORKSPACE` files.
|
|||
|
||||
1. Bazel support is enabled automatically
|
||||
2. Renovate will search repositories for any `WORKSPACE` files in the repository
|
||||
3. Existing dependencies will be extracted from `container_pull`, `git_repository`, `go_repository`, `maven_install`, and `http_archive`/`http_file` declarations
|
||||
3. Existing dependencies will be extracted from `container_pull`, `oci_pull`, `git_repository`, `go_repository`, `maven_install`, and `http_archive`/`http_file` declarations
|
||||
4. Renovate will replace any old versions with the latest version available
|
||||
|
||||
## git_repository
|
||||
|
|
|
@ -87,6 +87,29 @@ describe('modules/manager/bazel/extract', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('extracts dependencies for oci_pull deptype', () => {
|
||||
const res = extractPackageFile(
|
||||
codeBlock`
|
||||
oci_pull(
|
||||
name="hasura",
|
||||
image="index.docker.io/hasura/graphql-engine",
|
||||
# v1.0.0-alpha31.cli-migrations 11/28
|
||||
digest="sha256:a4e8d8c444ca04fe706649e82263c9f4c2a4229bc30d2a64561b5e1d20cc8548",
|
||||
tag="v1.0.0-alpha31.cli-migrations"
|
||||
)
|
||||
`
|
||||
);
|
||||
expect(res?.deps).toMatchObject([
|
||||
{
|
||||
currentDigest:
|
||||
'sha256:a4e8d8c444ca04fe706649e82263c9f4c2a4229bc30d2a64561b5e1d20cc8548',
|
||||
currentValue: 'v1.0.0-alpha31.cli-migrations',
|
||||
depType: 'oci_pull',
|
||||
packageName: 'index.docker.io/hasura/graphql-engine',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('check remote option in go_repository', () => {
|
||||
const successStory = extractPackageFile(
|
||||
codeBlock`
|
||||
|
|
|
@ -24,6 +24,7 @@ export function extractPackageFile(
|
|||
const replaceString = fragment.value;
|
||||
if (
|
||||
replaceString.startsWith('container_pull') ||
|
||||
replaceString.startsWith('oci_pull') ||
|
||||
replaceString.startsWith('git_repository') ||
|
||||
replaceString.startsWith('go_repository')
|
||||
) {
|
||||
|
|
|
@ -349,6 +349,34 @@ describe('modules/manager/bazel/rules/index', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('oci', () => {
|
||||
it('extracts oci dependencies', () => {
|
||||
expect(
|
||||
extractDepsFromFragmentData({ rule: 'foo_bar', name: 'foo_bar' })
|
||||
).toBeEmptyArray();
|
||||
|
||||
expect(
|
||||
extractDepsFromFragmentData({
|
||||
rule: 'oci_pull',
|
||||
name: 'foo_bar',
|
||||
tag: '1.2.3',
|
||||
digest: 'abcdef0123abcdef0123abcdef0123abcdef0123',
|
||||
image: 'example.com/foo/bar',
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
currentDigest: 'abcdef0123abcdef0123abcdef0123abcdef0123',
|
||||
currentValue: '1.2.3',
|
||||
datasource: 'docker',
|
||||
depName: 'foo_bar',
|
||||
depType: 'oci_pull',
|
||||
packageName: 'example.com/foo/bar',
|
||||
versioning: 'docker',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('maven', () => {
|
||||
it('extracts maven dependencies', () => {
|
||||
expect(
|
||||
|
|
|
@ -7,9 +7,11 @@ import { GitTarget, gitRules } from './git';
|
|||
import { GoTarget, goRules } from './go';
|
||||
import { HttpTarget, httpRules } from './http';
|
||||
import { MavenTarget, mavenRules } from './maven';
|
||||
import { OciTarget, ociRules } from './oci';
|
||||
|
||||
const Target = z.union([
|
||||
DockerTarget,
|
||||
OciTarget,
|
||||
GitTarget,
|
||||
GoTarget,
|
||||
HttpTarget,
|
||||
|
@ -22,6 +24,7 @@ const Target = z.union([
|
|||
*/
|
||||
const supportedRules = [
|
||||
...dockerRules,
|
||||
...ociRules,
|
||||
...gitRules,
|
||||
...goRules,
|
||||
...httpRules,
|
||||
|
|
26
lib/modules/manager/bazel/rules/oci.ts
Normal file
26
lib/modules/manager/bazel/rules/oci.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { z } from 'zod';
|
||||
import { DockerDatasource } from '../../../datasource/docker';
|
||||
import { id as dockerVersioning } from '../../../versioning/docker';
|
||||
import type { PackageDependency } from '../../types';
|
||||
|
||||
export const ociRules = ['oci_pull'] as const;
|
||||
|
||||
export const OciTarget = z
|
||||
.object({
|
||||
rule: z.enum(ociRules),
|
||||
name: z.string(),
|
||||
image: z.string(),
|
||||
tag: z.string().optional(),
|
||||
digest: z.string().optional(),
|
||||
})
|
||||
.transform(({ rule, name, image, tag, digest }): PackageDependency[] => [
|
||||
{
|
||||
datasource: DockerDatasource.id,
|
||||
versioning: dockerVersioning,
|
||||
depType: rule,
|
||||
depName: name,
|
||||
packageName: image,
|
||||
currentValue: tag,
|
||||
currentDigest: digest,
|
||||
},
|
||||
]);
|
Loading…
Reference in a new issue