Skip to content

Commit 78cab91

Browse files
authored
Merge pull request #368 from Icinga:fix/repo_lookup_local_path
Fix: Repository lookup on local path for ifw.repo.json Fixes lookup for local ifw.repo.json, in case the path was specified with `ifw.repo.json` included, like `C:\icinga\stable\ifw.repo.json`
2 parents b9e244a + e29ba83 commit 78cab91

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1919
* [#365](https://github.com/Icinga/icinga-powershell-framework/issues/365) Fixes Icinga environment corruption on Icinga Agent installation failure
2020
* [#366](https://github.com/Icinga/icinga-powershell-framework/issues/366) Fixes error handling with Icinga Director over IMC, by printing more detailed and user-friendly error messages
2121
* [#367](https://github.com/Icinga/icinga-powershell-framework/issues/367) Fixes Icinga Director register state not being saved on overview after registration of Host inside Self-Service API
22+
* [#368](https://github.com/Icinga/icinga-powershell-framework/issues/368) Fixes repository lookup on local path for ifw.repo.json, in the json file was added to the file path during repository add
2223

2324
### Enhancements
2425

lib/core/repository/Read-IcingaRepositoryFile.psm1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,23 @@ function Read-IcingaRepositoryFile()
2222

2323
if ([string]::IsNullOrEmpty($Repository.LocalPath) -eq $FALSE -And (Test-Path -Path $Repository.LocalPath)) {
2424
$RepoPath = $Repository.LocalPath;
25-
$Content = Get-Content -Path (Join-Path -Path $RepoPath -ChildPath 'ifw.repo.json') -Raw;
2625
} elseif ([string]::IsNullOrEmpty($Repository.RemotePath) -eq $FALSE -And (Test-Path -Path $Repository.RemotePath)) {
2726
$RepoPath = $Repository.RemotePath;
28-
$Content = Get-Content -Path (Join-Path -Path $RepoPath -ChildPath 'ifw.repo.json') -Raw;
27+
}
28+
29+
if ([string]::IsNullOrEmpty($RepoPath) -eq $FALSE -And (Test-Path -Path $RepoPath)) {
30+
if ([IO.Path]::GetExtension($RepoPath).ToLower() -ne '.json' -And $TryAlternate -eq $FALSE) {
31+
return (Read-IcingaRepositoryFile -Name $Name -TryAlternate);
32+
} elseif ([IO.Path]::GetExtension($RepoPath).ToLower() -ne '.json' -And $TryAlternat) {
33+
Write-IcingaConsoleError 'Unable to read repository file from "{0}" for repository "{1}". No "ifw.repo.json" was found at defined location' -Objects $RepoPath, $Name;
34+
return $null;
35+
}
36+
37+
if ($TryAlternate) {
38+
$RepoPath = Join-Path $RepoPath -ChildPath 'ifw.repo.json';
39+
}
40+
41+
$Content = Get-Content -Path $RepoPath -Raw;
2942
} else {
3043
try {
3144
$RepoPath = $Repository.RemotePath;

0 commit comments

Comments
 (0)