Skip to content

Commit

Permalink
🩹 [Patch]: Simplify context removal logic in Remove-Context by stre…
Browse files Browse the repository at this point in the history
…amlining secret retrieval and removal process
  • Loading branch information
MariusStorhaug committed Nov 22, 2024
1 parent d2fcbc2 commit a4edb0b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/functions/public/Context/Remove-Context.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@ filter Remove-Context {
[string] $ID
)

$contextVault = Get-ContextVault

$null = Get-ContextVault
$ID = "$($script:Config.SecretPrefix)$ID"

$contextName = Get-SecretInfo -Vault $script:Config.VaultName -Name $ID | Select-Object -ExpandProperty Name

Write-Verbose "Removing context [$ID] from [$($contextVault.Name)]"
if ($PSCmdlet.ShouldProcess('Remove-Secret', $contextName)) {
Write-Verbose "Removing secret [$contextName]"
Remove-Secret -Name $contextName -Vault $contextVault.Name
if ($PSCmdlet.ShouldProcess('Remove-Secret', $context.Name)) {
Get-SecretInfo -Vault $script:Config.VaultName | Where-Object { $_.Name -eq $ID } | Remove-Secret
}
}

0 comments on commit a4edb0b

Please sign in to comment.