Skip to content

Commit

Permalink
Refactor script execution logic to handle multiple paths and recursiv…
Browse files Browse the repository at this point in the history
…e search for .ps1 files

Signed-off-by: PixelRobots <22979170+PixelRobots@users.noreply.github.com>
  • Loading branch information
PixelRobots committed Oct 22, 2024
1 parent 1fd1f99 commit 21446cd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion KubeTidy.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'KubeTidy.psm1'

# Version number of this module.
ModuleVersion = '0.0.17'
ModuleVersion = '0.0.18'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
25 changes: 13 additions & 12 deletions KubeTidy.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ""

Expand Down Expand Up @@ -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
17 changes: 9 additions & 8 deletions Private/Merge-KubeConfigs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ function Show-KubeTidyBanner {
Write-Host " ██║ ██╗╚██████╔╝██████╔╝███████╗ ██║ ██║██████╔╝ ██║ " -ForegroundColor Cyan
Write-Host " ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ " -ForegroundColor Cyan
Write-Host ""
}
}

0 comments on commit 21446cd

Please sign in to comment.