diff --git a/src/steps/resource-manager/index.test.ts b/src/steps/resource-manager/index.test.ts index 23352216..310e811c 100644 --- a/src/steps/resource-manager/index.test.ts +++ b/src/steps/resource-manager/index.test.ts @@ -40,8 +40,14 @@ describe('flattenAuditLogConfigs', () => { { exemptedMembers: ['dev@j1.co', 'prod@j1.co'], logType: 'type2' }, ]), ).toEqual([ - { exemptedMember: 'dev@j1.co', logTypes: ['type1', 'type2'] }, - { exemptedMember: 'prod@j1.co', logTypes: ['type1', 'type2'] }, + { + exemptedMember: 'dev@j1.co', + logTypes: { 'logType.type1': true, 'logType.type2': true }, + }, + { + exemptedMember: 'prod@j1.co', + logTypes: { 'logType.type1': true, 'logType.type2': true }, + }, ]); }); @@ -50,7 +56,7 @@ describe('flattenAuditLogConfigs', () => { flattenAuditLogConfigs([ { exemptedMembers: ['dev@j1.co'], logType: null }, ]), - ).toEqual([{ exemptedMember: 'dev@j1.co', logTypes: [] }]); + ).toEqual([{ exemptedMember: 'dev@j1.co', logTypes: {} }]); }); test('should return empty array for `undefined` logType', () => { @@ -58,7 +64,7 @@ describe('flattenAuditLogConfigs', () => { flattenAuditLogConfigs([ { exemptedMembers: ['dev@j1.co'], logType: undefined }, ]), - ).toEqual([{ exemptedMember: 'dev@j1.co', logTypes: [] }]); + ).toEqual([{ exemptedMember: 'dev@j1.co', logTypes: {} }]); }); test('should skip `null` exemptedMembers', () => { diff --git a/src/steps/resource-manager/index.ts b/src/steps/resource-manager/index.ts index dbbb2596..f649e76e 100644 --- a/src/steps/resource-manager/index.ts +++ b/src/steps/resource-manager/index.ts @@ -334,7 +334,7 @@ export async function fetchIamPolicyAuditConfig( parsedMember, logger, projectId: client.projectId, - additionalProperties: { logTypes }, + additionalProperties: { ...logTypes }, relationshipClass: RelationshipClass.ALLOWS, }); @@ -357,7 +357,7 @@ export async function fetchIamPolicyAuditConfig( * => * * [ - * { exemptedMember: ['dev@j1.io'], logTypes: ['type1', 'type2' ] } + * { exemptedMember: ['dev@j1.io'], logTypes: { 'logType.type1': true, 'logType.type2': true } } * ] * */ @@ -365,7 +365,7 @@ export function flattenAuditLogConfigs( auditLogConfigs: cloudresourcemanager_v3.Schema$AuditLogConfig[], ): { exemptedMember: string; - logTypes: string[]; + logTypes: { [key: string]: boolean }; }[] { const exemptedMemberToLogTypesMap: { [exemptedMember: string]: string[] } = {}; @@ -384,7 +384,15 @@ export function flattenAuditLogConfigs( } return Object.entries(exemptedMemberToLogTypesMap).map( - ([exemptedMember, logTypes]) => ({ exemptedMember, logTypes }), + ([exemptedMember, logTypes]) => { + const parsedLogtype = {}; + + for (const logType of logTypes) { + parsedLogtype[`logType.${logType}`] = true; + } + + return { exemptedMember, logTypes: parsedLogtype }; + }, ); }