Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/core/repository/New-IcingaRepository.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion lib/core/repository/New-IcingaRepositoryFile.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ function New-IcingaRepositoryFile()
{
param (
[string]$Path = $null,
[string]$RemotePath = $null
[string]$RemotePath = $null,
[string]$Name = ''
);

$RepoFile = 'ifw.repo.json';
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions lib/core/repository/Sync-IcingaRepository.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
}
}

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/core/repository/Update-IcingaRepository.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 `
Expand Down