Skip to content

Commit

Permalink
fix(secret-list): fix secret list page error when secret is missing s…
Browse files Browse the repository at this point in the history
…tatus field
  • Loading branch information
karthikjeeyar committed Oct 25, 2023
1 parent 2fe2f5b commit b02853c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/components/Secrets/__tests___/secret-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ describe('getSecretRowData', () => {
});
});

it('should not throw error when the status field is missing in the newly created secret', () => {
const injectedSecret = sampleRemoteSecrets[RemoteSecretStatusReason.Injected];

const secretWithoutStatus = {
...injectedSecret,
status: undefined,
};

expect(getSecretRowData(secretWithoutStatus, ['development'])).toEqual({
secretFor: 'Build',
secretLabels: '-',
secretName: 'test-secret-two',
secretStatus: '-',
secretTarget: 'development',
secretType: 'Key/value',
});
});

it('should return the labels data for the given secret', () => {
const injectedSecret = sampleRemoteSecrets[RemoteSecretStatusReason.Injected];

Expand Down
3 changes: 2 additions & 1 deletion src/components/Secrets/utils/secret-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export const statusFromConditions = (

export const getSecretRowData = (obj: RemoteSecretKind, environmentNames: string[]): any => {
const type = typeToLabel(obj?.spec?.secret?.type);
const keys = obj?.status.secret?.keys;

const keys = obj?.status?.secret?.keys;
const secretName = obj?.spec?.secret?.name || '-';
const secretFor = obj?.metadata?.labels?.[SecretByUILabel] ?? SecretFor.Deployment;
const secretTarget =
Expand Down

0 comments on commit b02853c

Please sign in to comment.