Skip to content

Commit 188f3ca

Browse files
committed
Adds progress bar to repository interaction instead of text output
1 parent 3d22809 commit 188f3ca

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2727
* [#635](https://github.com/Icinga/icinga-powershell-framework/pull/635) Adds support for `Write-IcingaAgentApiConfig` function to configure the Icinga Agent TLS cipher list setting by new argument `-CipherList`
2828
* [#640](https://github.com/Icinga/icinga-powershell-framework/issues/640) Adds support to set the flag `-NoSSLValidation` for Cmdlets `icinga` and `Install-Icinga`, to ignore errors on self-signed certificates within the environment
2929
* [#643](https://github.com/Icinga/icinga-powershell-framework/pull/643) Adds support for `-RebuildCache` flag on `icinga` cmd to rebuild component cache as well
30+
* [#644](https://github.com/Icinga/icinga-powershell-framework/pull/644) Adds progress bar output to repository interaction (sync, update, new) instead of plain text output
3031

3132
## 1.10.1 (2022-12-20)
3233

lib/core/repository/New-IcingaRepository.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function New-IcingaRepository()
3535
return;
3636
}
3737

38-
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath;
38+
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath -Name $Name;
3939

4040
[array]$ConfigCount = $IcingaRepository.Packages.PSObject.Properties.Count;
4141

lib/core/repository/New-IcingaRepositoryFile.psm1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ function New-IcingaRepositoryFile()
22
{
33
param (
44
[string]$Path = $null,
5-
[string]$RemotePath = $null
5+
[string]$RemotePath = $null,
6+
[string]$Name = ''
67
);
78

89
$RepoFile = 'ifw.repo.json';
@@ -23,11 +24,15 @@ function New-IcingaRepositoryFile()
2324

2425
$RepositoryFolder = Get-ChildItem -Path $Path -Recurse -Include '*.msi', '*.zip';
2526

27+
New-IcingaProgressStatus -Name 'Updating Repository' -Message ([string]::Format('Update Icinga for Windows repository ({0}). Processed files', $Name)) -MaxValue $RepositoryFolder.Count -Details;
28+
2629
foreach ($entry in $RepositoryFolder) {
2730
$RepoFilePath = $entry.FullName.Replace($Path, '');
2831
$FileHash = Get-FileHash -Path $entry.FullName -Algorithm SHA256;
2932
$ComponentName = '';
3033

34+
Write-IcingaProgressStatus -Name 'Updating Repository';
35+
3136
$IcingaForWindowsPackage = New-Object -TypeName PSObject;
3237
$IcingaForWindowsPackage | Add-Member -MemberType NoteProperty -Name 'Hash' -Value $FileHash.Hash;
3338
$IcingaForWindowsPackage | Add-Member -MemberType NoteProperty -Name 'Location' -Value $RepoFilePath;
@@ -85,6 +90,8 @@ function New-IcingaRepositoryFile()
8590
$IcingaRepository.Info.RepoHash = Get-IcingaRepositoryHash -Path $Path;
8691
}
8792

93+
Complete-IcingaProgressStatus -Name 'Updating Repository';
94+
8895
Write-IcingaFileSecure -File $RepoPath -Value (ConvertTo-Json -InputObject $IcingaRepository -Depth 100);
8996

9097
return $IcingaRepository;

lib/core/repository/Sync-IcingaRepository.psm1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ function Sync-IcingaRepository()
116116
foreach ($component in $JsonRepo.Packages.PSObject.Properties.Name) {
117117
$IfWPackage = $JsonRepo.Packages.$component
118118

119+
New-IcingaProgressStatus -Name 'Sync Repository' -Message ([string]::Format('Syncing Icinga for Windows repository {0} ({1}). Downloaded {2} packages', $Name, $JsonRepo.Info.RemoteSource, $component)) -MaxValue $IfWPackage.Count -Details;
120+
119121
foreach ($package in $IfWPackage) {
120122
$DownloadLink = $package.Location;
121123
$TargetLocation = $TmpDir;
122124

125+
Write-IcingaProgressStatus -Name 'Sync Repository';
126+
123127
if ($package.RelativePath -eq $TRUE) {
124128
$DownloadLink = Join-WebPath -Path $JsonRepo.Info.RemoteSource -ChildPath $package.Location;
125129
$TargetLocation = Join-Path -Path $TmpDir -ChildPath $package.Location;
@@ -146,13 +150,15 @@ function Sync-IcingaRepository()
146150
}
147151

148152
try {
149-
Write-IcingaConsoleNotice 'Syncing repository component "{0}" as file "{1}" into temp directory' -Objects $component, $package.Location;
153+
Write-IcingaConsoleDebug 'Syncing repository component "{0}" as file "{1}" into temp directory' -Objects $component, $package.Location;
150154
Invoke-IcingaWebRequest -UseBasicParsing -Uri $DownloadLink -OutFile $TargetLocation | Out-Null;
151155
} catch {
152156
Write-IcingaConsoleError 'Failed to download repository component "{0}". Exception: "{1}"' -Objects $DownloadLink, $_.Exception.Message;
153157
continue;
154158
}
155159
}
160+
161+
Complete-IcingaProgressStatus -Name 'Sync Repository';
156162
}
157163
}
158164

@@ -187,7 +193,7 @@ function Sync-IcingaRepository()
187193
}
188194

189195
if ($HasNonRelative) {
190-
[void](New-IcingaRepositoryFile -Path $TmpDir -RemotePath $RemotePath);
196+
[void](New-IcingaRepositoryFile -Path $TmpDir -RemotePath $RemotePath -Name $Name);
191197
$RepoContent = Get-Content -Path $RepoFile -Raw;
192198
$JsonRepo = ConvertFrom-Json -InputObject $RepoContent;
193199
Start-Sleep -Seconds 2;

lib/core/repository/Update-IcingaRepository.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Update-IcingaRepository()
6767
$SetRemotePath = $RemotePath;
6868
}
6969

70-
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $SetRemotePath;
70+
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $SetRemotePath -Name $Name;
7171

7272
if ($CreateNew) {
7373
return $IcingaRepository;
@@ -97,7 +97,7 @@ function Update-IcingaRepository()
9797
$SetRemotePath = $RemotePath;
9898
}
9999

100-
Write-IcingaConsoleNotice 'Syncing repository "{0}"' -Objects $definedRepo.Name;
100+
Write-IcingaConsoleDebug 'Syncing repository "{0}"' -Objects $definedRepo.Name;
101101

102102
if ([string]::IsNullOrEmpty($definedRepo.Value.CloneSource) -eq $FALSE) {
103103
Sync-IcingaRepository `

0 commit comments

Comments
 (0)