Repository navigation
Fix missing IcingaProtocol configuration directory creation in New-IcingaProtocolEnvironment - #24
Merged
Conversation
…ingaProtocolEnvironment `Write-SecureFile` creates missing files via `New-SecureItem -ItemType File` without `-Force`. On freshly initialized hosts where `<ConfigDirectory>\IcingaProtocol` does not exist yet, `New-Item` failed with `DirectoryNotFoundException` and `Connection.json` was not written to disk. Resolve `$ProtocolConfigDir` and `$ProtocolConfigFile` once via `Join-Path`, reuse them across `-DryRun` and persistence, and create `$ProtocolConfigDir` via `New-SecureItem -ItemType 'Directory' -Force` prior to calling `Write-SecureFile`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ensures
New-IcingaProtocolEnvironmentcreates theIcingaProtocolsubdirectory inside the module configuration directory before persistingConnection.json.Why & Details
Write-SecureFiledelegates new file creation toNew-SecureItem -ItemType Filewithout-Force. On freshly initialized systems where<ConfigDirectory>\IcingaProtocoldoes not yet exist,New-Itemfailed withDirectoryNotFoundExceptionandConnection.jsonwas never written to disk.$ProtocolConfigDirand$ProtocolConfigFileonce viaJoin-Path(Get-ModuleConfigDirectory) and reuses them across-DryRun, directory creation, and file writing.$ProtocolConfigDirviaNew-SecureItem -ItemType 'Directory' -Path $ProtocolConfigDir -Forceprior to callingWrite-SecureFile(matchingAdd-ModuleWebSocketConfig).docs/General/Changelog.md.