Skip to content

Commit

Permalink
chore: improve isDefaultRepository readabilty
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmoz committed Aug 20, 2024
1 parent e1e4e00 commit 5d33e10
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/modules/manager/glasskube/extract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import is from '@sindresorhus/is';
import { readLocalFile } from '../../../util/fs';
import { parseYaml } from '../../../util/yaml';
import { GlasskubePackagesDatasource } from '../../datasource/glasskube-packages';
Expand Down Expand Up @@ -70,13 +71,15 @@ function findRepository(
name: string | null,
repositories: PackageRepository[],
): PackageRepository | null {
return (
repositories.find(
(it) =>
name === it.metadata.name ||
((name === null || name === '') && isDefaultRepository(it)),
) ?? null
);
for (const repository of repositories) {
if (name === repository.metadata.name) {
return repository;
}
if (is.falsy(name) && isDefaultRepository(repository)) {
return repository;
}
}
return null;
}

function isDefaultRepository(repository: PackageRepository): boolean {
Expand Down

0 comments on commit 5d33e10

Please sign in to comment.