Skip to content

Commit

Permalink
Merge pull request #527 from Icinga:feature/dev_mode_include_components
Browse files Browse the repository at this point in the history
Feature: Adds developer mode for components

Adds support for the developer mode to now include the modules as well and ensure, that available cache files are overwritten with the template again.

This ensures that we can develop new features and test them on the fly, without having to manipulate cache files manually.
  • Loading branch information
LordHepipud authored May 30, 2022
2 parents 384ab1c + 982ae84 commit 126ac28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion icinga-powershell-framework.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,18 @@ function Write-IcingaFrameworkCodeCache()

function Copy-IcingaFrameworkCacheTemplate()
{
Copy-Item -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\framework_cache.psm1.template') -Destination (Get-IcingaFrameworkCodeCacheFile) -Force;
Copy-ItemSecure -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\framework_cache.psm1.template') -Destination (Get-IcingaFrameworkCodeCacheFile) -Force | Out-Null;

$WindowsModules = Get-Module -Name 'icinga-powershell-*' -ListAvailable;

foreach ($entry in $WindowsModules) {
$ModulePath = $entry.Path.Replace([string]::Format('{0}.psd1', $entry.Name), '');
$CacheFile = Join-Path -Path $ModulePath -ChildPath ([string]::Format('\compiled\{0}.ifw_compilation.psm1', $entry.Name));

if (Test-Path $CacheFile) {
Copy-ItemSecure -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\compilation.psm1.template') -Destination $CacheFile -Force | Out-Null;
}
}
}

function Publish-IcingaEventLogDocumentation()
Expand Down
4 changes: 4 additions & 0 deletions templates/compilation.psm1.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ if ($null -eq (Get-Command -Name 'Write-IcingaForWindowsComponentCompilationFile
Write-IcingaForWindowsComponentCompilationFile `
-ScriptRootPath $PSScriptRoot `
-CompiledFilePath ($MyInvocation.MyCommand.Path);

if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate;
}

0 comments on commit 126ac28

Please sign in to comment.