From 3ccc760b84dd6163e4783e72f2f2c983eab14b49 Mon Sep 17 00:00:00 2001 From: PixelRobots <22979170+PixelRobots@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:55:35 +0100 Subject: [PATCH] Refactor publish-krewplugin.yaml to update Invoke-KubeTidy function and modify param block Signed-off-by: PixelRobots <22979170+PixelRobots@users.noreply.github.com> --- .github/workflows/publish-krewplugin.yaml | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish-krewplugin.yaml b/.github/workflows/publish-krewplugin.yaml index 6f1199d..10e279d 100644 --- a/.github/workflows/publish-krewplugin.yaml +++ b/.github/workflows/publish-krewplugin.yaml @@ -68,29 +68,22 @@ jobs: continue } - # Comment out or remove the existing param block - if ($line -match 'param\s*\(' -and $insideParamBlock) { - $newLines += "# $line" # Comment out the line - continue + # Comment out the existing param block if found + if ($line -match '# START PARAM BLOCK') { + continue # Skip adding this line + } + if ($line -match '# END PARAM BLOCK') { + continue # Skip adding this line } # Add the line to newLines if it is not part of the removed param block $newLines += $line - - # Check for the start of the existing param block to set the flag - if ($line -match 'param\s*\(') { - $insideParamBlock = $true - } - - # Check for the end of the existing param block - if ($line -match '\)') { - $insideParamBlock = $false - } } - # Add the function call marker without the comment + # Add the function call line directly $newLines += "`n# MARKER: FUNCTION CALL" - + $newLines += "Invoke-KubeTidy \$PSBoundParameters" + # Write the updated content back to the file Set-Content -Path $destinationFile -Value $newLines -Force