Skip to content

Commit

Permalink
Merge pull request #603 from kubeshop/f1ames/fix/require-suppression-…
Browse files Browse the repository at this point in the history
…location

Allow passing suppression location
  • Loading branch information
f1ames authored Feb 9, 2024
2 parents e03d1cd + 90cbcd1 commit 40ae9ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-donkeys-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@monokle/synchronizer": patch
---

Suppression location can now be passed 'toggleSuppression' API
10 changes: 5 additions & 5 deletions packages/synchronizer/src/handlers/apiHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ const getRepoIdQuery = `
`;

const toggleSuppressionMutation = `
mutation toggleSuppression($fingerprint: String!, $repoId: ID!, $description: String!) {
mutation toggleSuppression($fingerprint: String!, $repoId: ID!, $description: String!, $location: String) {
toggleSuppression(
input: {fingerprint: $fingerprint, repository: $repoId, description: $description, skipReview: true}
input: {fingerprint: $fingerprint, repository: $repoId, description: $description, location: $location, skipReview: true}
) {
id
fingerprint
Expand Down Expand Up @@ -243,7 +243,7 @@ export type ApiSuppression = {
id: string;
fingerprint: string;
description: string;
locations: string;
location: string;
status: SuppressionStatus;
justification: string;
expiresAt: string;
Expand Down Expand Up @@ -402,8 +402,8 @@ export class ApiHandler {
return this.queryApi(getRepoIdQuery, tokenInfo, {projectSlug, repoOwner, repoName});
}

async toggleSuppression(fingerprint: string, repoId: string, description: string, tokenInfo: TokenInfo) {
return this.queryApi<ApiSuppressionsData>(toggleSuppressionMutation, tokenInfo, {fingerprint, repoId, description});
async toggleSuppression(fingerprint: string, repoId: string, description: string, location: string | undefined, tokenInfo: TokenInfo) {
return this.queryApi<ApiSuppressionsData>(toggleSuppressionMutation, tokenInfo, {fingerprint, repoId, description, location});
}

generateDeepLink(path: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/synchronizer/src/utils/projectSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class ProjectSynchronizer extends EventEmitter {
return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.suppressions ?? [];
}

async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, rootPath: string, projectSlug?: string) {
async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, location: string | undefined, rootPath: string, projectSlug?: string) {
if (!tokenInfo?.accessToken?.length) {
throw new Error('Cannot use suppressions without access token.');
}
Expand All @@ -105,7 +105,7 @@ export class ProjectSynchronizer extends EventEmitter {
throw new Error('Cannot suppress due to missing repository id or project slug!');
}

const suppressionResult = await this._apiHandler.toggleSuppression(fingerprint, id, description, tokenInfo);
const suppressionResult = await this._apiHandler.toggleSuppression(fingerprint, id, description, location, tokenInfo);
if (suppressionResult?.data?.getSuppressions?.data?.length) {
const existingSuppressions = await this.readSuppressions(repoData);
const allSuppressions = this.mergeSuppressions(existingSuppressions, suppressionResult.data.getSuppressions.data);
Expand Down

0 comments on commit 40ae9ea

Please sign in to comment.