mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
Merge pull request #644 from Icinga:feature/improve_repo_handling_by_using_progress_preference
Feature: Adds progress bar to repository interaction instead of text output Instead of writing every file processed within the console output, we now use the progress bar handling to provide a better idea on how many files have been processed during a sync and update.  In addition, creating new repositories will now give an overview on how many files have been processed so far including the remaining files, instead of waiting for the shell to complete the task without any output. 
This commit is contained in:
commit
68aba5f1d4
5 changed files with 20 additions and 6 deletions
|
|
@ -27,6 +27,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
* [#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`
|
||||
* [#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
|
||||
* [#643](https://github.com/Icinga/icinga-powershell-framework/pull/643) Adds support for `-RebuildCache` flag on `icinga` cmd to rebuild component cache as well
|
||||
* [#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
|
||||
|
||||
## 1.10.1 (2022-12-20)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function New-IcingaRepository()
|
|||
return;
|
||||
}
|
||||
|
||||
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath;
|
||||
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $RemotePath -Name $Name;
|
||||
|
||||
[array]$ConfigCount = $IcingaRepository.Packages.PSObject.Properties.Count;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ function New-IcingaRepositoryFile()
|
|||
{
|
||||
param (
|
||||
[string]$Path = $null,
|
||||
[string]$RemotePath = $null
|
||||
[string]$RemotePath = $null,
|
||||
[string]$Name = ''
|
||||
);
|
||||
|
||||
$RepoFile = 'ifw.repo.json';
|
||||
|
|
@ -23,11 +24,15 @@ function New-IcingaRepositoryFile()
|
|||
|
||||
$RepositoryFolder = Get-ChildItem -Path $Path -Recurse -Include '*.msi', '*.zip';
|
||||
|
||||
New-IcingaProgressStatus -Name 'Updating Repository' -Message ([string]::Format('Update Icinga for Windows repository ({0}). Processed files', $Name)) -MaxValue $RepositoryFolder.Count -Details;
|
||||
|
||||
foreach ($entry in $RepositoryFolder) {
|
||||
$RepoFilePath = $entry.FullName.Replace($Path, '');
|
||||
$FileHash = Get-FileHash -Path $entry.FullName -Algorithm SHA256;
|
||||
$ComponentName = '';
|
||||
|
||||
Write-IcingaProgressStatus -Name 'Updating Repository';
|
||||
|
||||
$IcingaForWindowsPackage = New-Object -TypeName PSObject;
|
||||
$IcingaForWindowsPackage | Add-Member -MemberType NoteProperty -Name 'Hash' -Value $FileHash.Hash;
|
||||
$IcingaForWindowsPackage | Add-Member -MemberType NoteProperty -Name 'Location' -Value $RepoFilePath;
|
||||
|
|
@ -85,6 +90,8 @@ function New-IcingaRepositoryFile()
|
|||
$IcingaRepository.Info.RepoHash = Get-IcingaRepositoryHash -Path $Path;
|
||||
}
|
||||
|
||||
Complete-IcingaProgressStatus -Name 'Updating Repository';
|
||||
|
||||
Write-IcingaFileSecure -File $RepoPath -Value (ConvertTo-Json -InputObject $IcingaRepository -Depth 100);
|
||||
|
||||
return $IcingaRepository;
|
||||
|
|
|
|||
|
|
@ -116,10 +116,14 @@ function Sync-IcingaRepository()
|
|||
foreach ($component in $JsonRepo.Packages.PSObject.Properties.Name) {
|
||||
$IfWPackage = $JsonRepo.Packages.$component
|
||||
|
||||
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;
|
||||
|
||||
foreach ($package in $IfWPackage) {
|
||||
$DownloadLink = $package.Location;
|
||||
$TargetLocation = $TmpDir;
|
||||
|
||||
Write-IcingaProgressStatus -Name 'Sync Repository';
|
||||
|
||||
if ($package.RelativePath -eq $TRUE) {
|
||||
$DownloadLink = Join-WebPath -Path $JsonRepo.Info.RemoteSource -ChildPath $package.Location;
|
||||
$TargetLocation = Join-Path -Path $TmpDir -ChildPath $package.Location;
|
||||
|
|
@ -146,13 +150,15 @@ function Sync-IcingaRepository()
|
|||
}
|
||||
|
||||
try {
|
||||
Write-IcingaConsoleNotice 'Syncing repository component "{0}" as file "{1}" into temp directory' -Objects $component, $package.Location;
|
||||
Write-IcingaConsoleDebug 'Syncing repository component "{0}" as file "{1}" into temp directory' -Objects $component, $package.Location;
|
||||
Invoke-IcingaWebRequest -UseBasicParsing -Uri $DownloadLink -OutFile $TargetLocation | Out-Null;
|
||||
} catch {
|
||||
Write-IcingaConsoleError 'Failed to download repository component "{0}". Exception: "{1}"' -Objects $DownloadLink, $_.Exception.Message;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Complete-IcingaProgressStatus -Name 'Sync Repository';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +193,7 @@ function Sync-IcingaRepository()
|
|||
}
|
||||
|
||||
if ($HasNonRelative) {
|
||||
[void](New-IcingaRepositoryFile -Path $TmpDir -RemotePath $RemotePath);
|
||||
[void](New-IcingaRepositoryFile -Path $TmpDir -RemotePath $RemotePath -Name $Name);
|
||||
$RepoContent = Get-Content -Path $RepoFile -Raw;
|
||||
$JsonRepo = ConvertFrom-Json -InputObject $RepoContent;
|
||||
Start-Sleep -Seconds 2;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ function Update-IcingaRepository()
|
|||
$SetRemotePath = $RemotePath;
|
||||
}
|
||||
|
||||
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $SetRemotePath;
|
||||
$IcingaRepository = New-IcingaRepositoryFile -Path $Path -RemotePath $SetRemotePath -Name $Name;
|
||||
|
||||
if ($CreateNew) {
|
||||
return $IcingaRepository;
|
||||
|
|
@ -97,7 +97,7 @@ function Update-IcingaRepository()
|
|||
$SetRemotePath = $RemotePath;
|
||||
}
|
||||
|
||||
Write-IcingaConsoleNotice 'Syncing repository "{0}"' -Objects $definedRepo.Name;
|
||||
Write-IcingaConsoleDebug 'Syncing repository "{0}"' -Objects $definedRepo.Name;
|
||||
|
||||
if ([string]::IsNullOrEmpty($definedRepo.Value.CloneSource) -eq $FALSE) {
|
||||
Sync-IcingaRepository `
|
||||
|
|
|
|||
Loading…
Reference in a new issue