From 21446cdd6618a9e62a704e1fbe94b692259373da Mon Sep 17 00:00:00 2001 From: PixelRobots <22979170+PixelRobots@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:14:40 +0100 Subject: [PATCH] Refactor script execution logic to handle multiple paths and recursive search for .ps1 files Signed-off-by: PixelRobots <22979170+PixelRobots@users.noreply.github.com> --- CHANGELOG.md | 5 ++++ KubeTidy.psd1 | 2 +- KubeTidy.psm1 | 25 ++++++++++--------- Private/Merge-KubeConfigs.ps1 | 17 +++++++------ ...Banner.ps1 => Show-KubeTidyBanner.ps1.old} | 2 +- 5 files changed, 29 insertions(+), 22 deletions(-) rename Private/{Show-KubeTidyBanner.ps1 => Show-KubeTidyBanner.ps1.old} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 696cde8..c721f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.18] - 2024-10-22 + +### Changed +- **Removed ASCII Art Banner**: The ASCII art banner was removed from the KubeTidy output as it was not displaying correctly in the new KubeDeck UI. This change improves compatibility with the user interface and enhances the overall visual clarity of the output. + ## [0.0.17] - 2024-10-17 ### Added diff --git a/KubeTidy.psd1 b/KubeTidy.psd1 index 100c9d3..bc7ce1b 100644 --- a/KubeTidy.psd1 +++ b/KubeTidy.psd1 @@ -12,7 +12,7 @@ RootModule = 'KubeTidy.psm1' # Version number of this module. -ModuleVersion = '0.0.17' +ModuleVersion = '0.0.18' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/KubeTidy.psm1 b/KubeTidy.psm1 index 6c2bc83..19a8998 100644 --- a/KubeTidy.psm1 +++ b/KubeTidy.psm1 @@ -173,7 +173,7 @@ function Invoke-KubeTidy { if (-not $DestinationConfig) { $DestinationConfig = "$env:USERPROFILE\.kube\config" } - Show-KubeTidyBanner + #Show-KubeTidyBanner Write-Host "Merging kubeconfig files..." -ForegroundColor Yellow # Call Merge-KubeConfigs with -DryRun only if $DryRun is True @@ -190,25 +190,25 @@ function Invoke-KubeTidy { if (-not $DestinationConfig) { $DestinationConfig = "$HOME/.kube/filtered-config" # Default destination for export } - Show-KubeTidyBanner + #Show-KubeTidyBanner Write-Host "Exporting specified contexts: `n$ExportContexts`n" -ForegroundColor Yellow Export-KubeContexts -KubeConfigPath $KubeConfigPath -Contexts $ExportContexts -OutputFile $DestinationConfig return } if ($ListClusters) { - Show-KubeTidyBanner + #Show-KubeTidyBanner Get-AllClusters -KubeConfigPath $KubeConfigPath return } if ($ListContexts) { - Show-KubeTidyBanner + #Show-KubeTidyBanner Get-KubeContexts -KubeConfigPath $KubeConfigPath return } - Show-KubeTidyBanner + #Show-KubeTidyBanner Write-Host "Starting KubeTidy cleanup..." -ForegroundColor Yellow Write-Host "" @@ -362,13 +362,14 @@ preferences: {} `n $retainedCountText = "{0,5}" -f ($checkedClusters - $removedCount) Write-Host "" - Write-Host "╔════════════════════════════════════════════════╗" -ForegroundColor Magenta - Write-Host "║ KubeTidy Summary ║" -ForegroundColor Magenta - Write-Host "╠════════════════════════════════════════════════╣" -ForegroundColor Magenta - Write-Host "║ Clusters Checked: $checkedClustersText ║" -ForegroundColor Yellow - Write-Host "║ Clusters Removed: $removedCountText ║" -ForegroundColor Red - Write-Host "║ Clusters Kept: $retainedCountText ║" -ForegroundColor Green - Write-Host "╚════════════════════════════════════════════════╝" -ForegroundColor Magenta + Write-Host "===============================================" -ForegroundColor Magenta + Write-Host " KubeTidy Summary " -ForegroundColor Magenta + Write-Host "===============================================" -ForegroundColor Magenta + Write-Host "Clusters Checked: $checkedClustersText" -ForegroundColor Yellow + Write-Host "Clusters Removed: $removedCountText" -ForegroundColor Red + Write-Host "Clusters Kept: $retainedCountText" -ForegroundColor Green + Write-Host "===============================================" -ForegroundColor Magenta + } # MARKER: FUNCTION CALL diff --git a/Private/Merge-KubeConfigs.ps1 b/Private/Merge-KubeConfigs.ps1 index df1d4d3..4280987 100644 --- a/Private/Merge-KubeConfigs.ps1 +++ b/Private/Merge-KubeConfigs.ps1 @@ -92,13 +92,14 @@ users: `n # Display summary of merged entities Write-Host "" - Write-Host "╔════════════════════════════════════════════════╗" -ForegroundColor Magenta - Write-Host "║ KubeTidy Merge Summary ║" -ForegroundColor Magenta - Write-Host "╠════════════════════════════════════════════════╣" -ForegroundColor Magenta - Write-Host "║ Files Merged: $($MergeConfigs.Count) ║" -ForegroundColor Yellow - Write-Host "║ Clusters Merged: $($mergedClusters.Count) ║" -ForegroundColor Cyan - Write-Host "║ Contexts Merged: $($mergedContexts.Count) ║" -ForegroundColor Cyan - Write-Host "║ Users Merged: $($mergedUsers.Count) ║" -ForegroundColor Cyan - Write-Host "╚════════════════════════════════════════════════╝" -ForegroundColor Magenta + Write-Host "===============================================" -ForegroundColor Magenta + Write-Host " KubeTidy Merge Summary " -ForegroundColor Magenta + Write-Host "===============================================" -ForegroundColor Magenta + Write-Host "Files Merged: $($MergeConfigs.Count)" -ForegroundColor Yellow + Write-Host "Clusters Merged: $($mergedClusters.Count)" -ForegroundColor Cyan + Write-Host "Contexts Merged: $($mergedContexts.Count)" -ForegroundColor Cyan + Write-Host "Users Merged: $($mergedUsers.Count)" -ForegroundColor Cyan + Write-Host "===============================================" -ForegroundColor Magenta Write-Host "" + } diff --git a/Private/Show-KubeTidyBanner.ps1 b/Private/Show-KubeTidyBanner.ps1.old similarity index 99% rename from Private/Show-KubeTidyBanner.ps1 rename to Private/Show-KubeTidyBanner.ps1.old index 0f21f5a..cf99f6f 100644 --- a/Private/Show-KubeTidyBanner.ps1 +++ b/Private/Show-KubeTidyBanner.ps1.old @@ -9,4 +9,4 @@ function Show-KubeTidyBanner { Write-Host " ██║ ██╗╚██████╔╝██████╔╝███████╗ ██║ ██║██████╔╝ ██║ " -ForegroundColor Cyan Write-Host " ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ " -ForegroundColor Cyan Write-Host "" -} \ No newline at end of file +}