Skip to content

Commit

Permalink
bugfix: Remove secret when deleting destination (#77)
Browse files Browse the repository at this point in the history
This PR adds the removal of a secret (if exists) when deleting a
destination.
This bug caused the creation of a destination with the same name as the
deleted destination to fail.
  • Loading branch information
edeNFed authored Feb 19, 2023
1 parent f7b0ccf commit 0e75fa3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ yarn-error.log*

# typescript
*.tsbuildinfo
.vscode
15 changes: 15 additions & 0 deletions ui/pages/api/dest/[destname].ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ async function DeleteDest(req: NextApiRequest, res: NextApiResponse) {
"destinations",
req.query.destname as string
);

// if secret with name req.query.destname exists, delete it
const coreApi = kc.makeApiClient(k8s.CoreV1Api);
const secret = await coreApi.readNamespacedSecret(
req.query.destname as string,
process.env.CURRENT_NS || "odigos-system"
);

if (secret) {
await coreApi.deleteNamespacedSecret(
req.query.destname as string,
process.env.CURRENT_NS || "odigos-system"
);
}

return res.status(200).json({ success: true });
}

Expand Down

0 comments on commit 0e75fa3

Please sign in to comment.