Skip to content

Commit

Permalink
add types for FluxManagerData
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Oct 8, 2022
1 parent ec0b816 commit c70fba8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/modules/manager/flux/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import type { ExecOptions } from '../../../util/exec/types';
import { readLocalFile } from '../../../util/fs';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { isSystemManifest } from './common';
import type { FluxManagerData } from './types';

export async function updateArtifacts({
packageFileName,
updatedDeps,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
}: UpdateArtifact<FluxManagerData>): Promise<UpdateArtifactsResult[] | null> {
const systemDep = updatedDeps[0];
if (!isSystemManifest(packageFileName) || !systemDep?.newVersion) {
return null;
Expand Down
19 changes: 12 additions & 7 deletions lib/modules/manager/flux/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { HelmDatasource } from '../../datasource/helm';
import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
import { isSystemManifest } from './common';
import type { FluxManifest, FluxResource, ResourceFluxManifest } from './types';
import type {
FluxManagerData,
FluxManifest,
FluxResource,
ResourceFluxManifest,
} from './types';

function readManifest(content: string, file: string): FluxManifest | null {
if (isSystemManifest(file)) {
Expand Down Expand Up @@ -68,14 +73,14 @@ function readManifest(content: string, file: string): FluxManifest | null {
function resolveManifest(
manifest: FluxManifest,
context: FluxManifest[]
): PackageDependency[] | null {
): PackageDependency<FluxManagerData>[] | null {
const resourceManifests = context.filter(
(manifest) => manifest.kind === 'resource'
) as ResourceFluxManifest[];
const repositories = resourceManifests.flatMap(
(manifest) => manifest.repositories
);
let res: PackageDependency[] | null = null;
let res: PackageDependency<FluxManagerData>[] | null = null;
switch (manifest.kind) {
case 'system':
res = [
Expand All @@ -91,7 +96,7 @@ function resolveManifest(
break;
case 'resource':
res = manifest.releases.map((release) => {
const dep: PackageDependency = {
const dep: PackageDependency<FluxManagerData> = {
depName: release.spec.chart.spec.chart,
currentValue: release.spec.chart.spec.version,
datasource: HelmDatasource.id,
Expand Down Expand Up @@ -122,7 +127,7 @@ function resolveManifest(
export function extractPackageFile(
content: string,
packageFile: string
): PackageFile | null {
): PackageFile<FluxManagerData> | null {
const manifest = readManifest(content, packageFile);
if (!manifest) {
return null;
Expand All @@ -134,9 +139,9 @@ export function extractPackageFile(
export async function extractAllPackageFiles(
_config: ExtractConfig,
packageFiles: string[]
): Promise<PackageFile[] | null> {
): Promise<PackageFile<FluxManagerData>[] | null> {
const manifests: FluxManifest[] = [];
const results: PackageFile[] = [];
const results: PackageFile<FluxManagerData>[] = [];

for (const file of packageFiles) {
const content = await readLocalFile(file, 'utf8');
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/manager/flux/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export type FluxManagerData = {
components: string;
};

export interface KubernetesResource {
apiVersion: string;
metadata: {
Expand Down

0 comments on commit c70fba8

Please sign in to comment.