Skip to content
Snippets Groups Projects
Unverified Commit 4cc21fa1 authored by mugi's avatar mugi Committed by GitHub
Browse files

feat(manager/helmfile): use the specific helmfile version that specified in...

feat(manager/helmfile): use the specific helmfile version that specified in the helmfile.lock. (#22904)
parent 8ec95278
No related branches found
No related tags found
No related merge requests found
...@@ -325,7 +325,7 @@ describe('modules/manager/helmfile/artifacts', () => { ...@@ -325,7 +325,7 @@ describe('modules/manager/helmfile/artifacts', () => {
'bash -l -c "' + 'bash -l -c "' +
'install-tool helm v3.7.2' + 'install-tool helm v3.7.2' +
' && ' + ' && ' +
'install-tool helmfile v0.129.0' + 'install-tool helmfile 0.151.0' +
' && ' + ' && ' +
'install-tool kustomize 5.0.0' + 'install-tool kustomize 5.0.0' +
' && ' + ' && ' +
...@@ -338,7 +338,7 @@ describe('modules/manager/helmfile/artifacts', () => { ...@@ -338,7 +338,7 @@ describe('modules/manager/helmfile/artifacts', () => {
binarySource: 'install', binarySource: 'install',
expectedCommands: [ expectedCommands: [
{ cmd: 'install-tool helm v3.7.2' }, { cmd: 'install-tool helm v3.7.2' },
{ cmd: 'install-tool helmfile v0.129.0' }, { cmd: 'install-tool helmfile 0.151.0' },
{ cmd: 'install-tool kustomize 5.0.0' }, { cmd: 'install-tool kustomize 5.0.0' },
{ cmd: 'helmfile deps -f helmfile.yaml' }, { cmd: 'helmfile deps -f helmfile.yaml' },
], ],
...@@ -359,9 +359,6 @@ describe('modules/manager/helmfile/artifacts', () => { ...@@ -359,9 +359,6 @@ describe('modules/manager/helmfile/artifacts', () => {
datasource.getPkgReleases.mockResolvedValueOnce({ datasource.getPkgReleases.mockResolvedValueOnce({
releases: [{ version: 'v3.7.2' }], releases: [{ version: 'v3.7.2' }],
}); });
datasource.getPkgReleases.mockResolvedValueOnce({
releases: [{ version: 'v0.129.0' }],
});
datasource.getPkgReleases.mockResolvedValueOnce({ datasource.getPkgReleases.mockResolvedValueOnce({
releases: [{ version: '5.0.0' }], releases: [{ version: '5.0.0' }],
}); });
......
...@@ -14,7 +14,12 @@ import { getFile } from '../../../util/git'; ...@@ -14,7 +14,12 @@ import { getFile } from '../../../util/git';
import { regEx } from '../../../util/regex'; import { regEx } from '../../../util/regex';
import { generateHelmEnvs } from '../helmv3/common'; import { generateHelmEnvs } from '../helmv3/common';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { generateRegistryLoginCmd, isOCIRegistry, parseDoc } from './utils'; import {
generateRegistryLoginCmd,
isOCIRegistry,
parseDoc,
parseLock,
} from './utils';
export async function updateArtifacts({ export async function updateArtifacts({
packageFileName, packageFileName,
...@@ -51,7 +56,9 @@ export async function updateArtifacts({ ...@@ -51,7 +56,9 @@ export async function updateArtifacts({
}, },
{ {
toolName: 'helmfile', toolName: 'helmfile',
constraint: config.constraints?.helmfile, constraint:
config.constraints?.helmfile ??
parseLock(existingLockFileContent).version,
}, },
]; ];
const needKustomize = updatedDeps.some( const needKustomize = updatedDeps.some(
......
...@@ -19,3 +19,7 @@ export const DocSchema = z.object({ ...@@ -19,3 +19,7 @@ export const DocSchema = z.object({
releases: z.array(ReleaseSchema).optional(), releases: z.array(ReleaseSchema).optional(),
repositories: z.array(RepositorySchema).optional(), repositories: z.array(RepositorySchema).optional(),
}); });
export const LockSchema = z.object({
version: z.string(),
});
import type { z } from 'zod'; import type { z } from 'zod';
import type { DocSchema, ReleaseSchema, RepositorySchema } from './schema'; import type {
DocSchema,
LockSchema,
ReleaseSchema,
RepositorySchema,
} from './schema';
export type Release = z.infer<typeof ReleaseSchema>; export type Release = z.infer<typeof ReleaseSchema>;
export type Repository = z.infer<typeof RepositorySchema>; export type Repository = z.infer<typeof RepositorySchema>;
export type Doc = z.infer<typeof DocSchema>; export type Doc = z.infer<typeof DocSchema>;
export type Lock = z.infer<typeof LockSchema>;
...@@ -7,8 +7,8 @@ import { DockerDatasource } from '../../datasource/docker'; ...@@ -7,8 +7,8 @@ import { DockerDatasource } from '../../datasource/docker';
import { generateLoginCmd } from '../helmv3/common'; import { generateLoginCmd } from '../helmv3/common';
import type { RepositoryRule } from '../helmv3/types'; import type { RepositoryRule } from '../helmv3/types';
import { DocSchema } from './schema'; import { DocSchema, LockSchema } from './schema';
import type { Doc, Release, Repository } from './types'; import type { Doc, Lock, Release, Repository } from './types';
/** Returns true if a helmfile release contains kustomize specific keys **/ /** Returns true if a helmfile release contains kustomize specific keys **/
export function kustomizationsKeysUsed(release: Release): boolean { export function kustomizationsKeysUsed(release: Release): boolean {
...@@ -36,6 +36,11 @@ export function parseDoc(packageFileContent: string): Doc { ...@@ -36,6 +36,11 @@ export function parseDoc(packageFileContent: string): Doc {
return DocSchema.parse(doc); return DocSchema.parse(doc);
} }
export function parseLock(lockFileContent: string): Lock {
const lock = yaml.load(lockFileContent);
return LockSchema.parse(lock);
}
export function isOCIRegistry(repository: Repository): boolean { export function isOCIRegistry(repository: Repository): boolean {
return repository.oci === true; return repository.oci === true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment