Skip to content

Commit

Permalink
Merge pull request #841 from karthikjeeyar/fix-secret-list
Browse files Browse the repository at this point in the history
fix(secret-list): fix secret list page error when secret is missing status field
  • Loading branch information
openshift-ci[bot] authored Oct 25, 2023
2 parents 2fe2f5b + b02853c commit 507a193
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 507a193

Please sign in to comment.