) =>
+ cellData.cell.row.original?.isReady != null ? (
+
+ ) : null,
+ },
+ {
+ Header: t('FluxList.tableCreatedHeader'),
+ accessor: 'created',
+ },
+ ];
+
+ const gitReposRows: FluxRow[] =
+ gitReposData?.items?.map((item) => {
+ return {
+ name: item.metadata.name,
+ isReady:
+ item.status.conditions.find((x) => x.type === 'Ready')?.status ===
+ 'True',
+ statusUpdateTime: item.status.conditions.find((x) => x.type === 'Ready')
+ ?.lastTransitionTime,
+ revision: shortenCommitHash(item.status.artifact.revision),
+ created: timeAgo.format(new Date(item.metadata.creationTimestamp)),
+ };
+ }) ?? [];
+
+ const kustomizationsRows: FluxRow[] =
+ kustmizationData?.items?.map((item) => {
+ return {
+ name: item.metadata.name,
+ isReady:
+ item.status.conditions.find((x) => x.type === 'Ready')?.status ===
+ 'True',
+ statusUpdateTime: item.status.conditions.find((x) => x.type === 'Ready')
+ ?.lastTransitionTime,
+ created: timeAgo.format(new Date(item.metadata.creationTimestamp)),
+ };
+ }) ?? [];
+
return (
<>
- Git Repos
-
- Kustomizations
-
+ {' '}
+
+
{t('FluxList.gitOpsTitle')}
+
+
+
+
{t('FluxList.kustomizationsTitle')}
+
+
>
);
}
+
+function shortenCommitHash(commitHash: string): string {
+ //example hash: master@sha1:b3396adb98a6a0f5eeedd1a600beaf5e954a1f28
+ const match = commitHash.match(/^([a-zA-Z0-9-_]+)@sha1:([a-f0-9]{40})/);
+
+ if (match && match[2]) {
+ return `${match[1]}@${match[2].slice(0, 7)}`;
+ }
+
+ //example output : master@b3396ad
+ return commitHash;
+}
diff --git a/src/lib/api/types/flux/listGitRepo.ts b/src/lib/api/types/flux/listGitRepo.ts
index d989514d..3c2c6f87 100644
--- a/src/lib/api/types/flux/listGitRepo.ts
+++ b/src/lib/api/types/flux/listGitRepo.ts
@@ -1,6 +1,32 @@
import { Resource } from '../resource';
-export const FluxGitRepo: Resource = {
+export type GitReposResponse = {
+ items: [
+ {
+ spec: {
+ package: string;
+ };
+ kind: string;
+ metadata: {
+ name: string;
+ creationTimestamp: string;
+ };
+ status: {
+ artifact: {
+ revision: string;
+ };
+ conditions: [
+ {
+ status: string;
+ type: string;
+ lastTransitionTime: string;
+ },
+ ];
+ };
+ },
+ ];
+};
+
+export const FluxRequest: Resource = {
path: '/apis/source.toolkit.fluxcd.io/v1/gitrepositories',
- jq: '[.items[]]',
};
diff --git a/src/lib/api/types/flux/listKustomization.ts b/src/lib/api/types/flux/listKustomization.ts
index 490a9507..0efff18e 100644
--- a/src/lib/api/types/flux/listKustomization.ts
+++ b/src/lib/api/types/flux/listKustomization.ts
@@ -1,6 +1,32 @@
import { Resource } from '../resource';
-export const FluxKustomization: Resource = {
+export type KustomizationsResponse = {
+ items: [
+ {
+ spec: {
+ package: string;
+ };
+ kind: string;
+ metadata: {
+ name: string;
+ creationTimestamp: string;
+ };
+ status: {
+ artifact: {
+ revision: string;
+ };
+ conditions: [
+ {
+ status: string;
+ type: string;
+ lastTransitionTime: string;
+ },
+ ];
+ };
+ },
+ ];
+};
+
+export const FluxKustomization: Resource = {
path: '/apis/kustomize.toolkit.fluxcd.io/v1/kustomizations',
- jq: '[.items[]]',
};