Skip to content

BREAKING CHANGE: OfficeOnlineServerFarm: Added 'IsSingleInstance' parameter #65

Open
JonasRied wants to merge 7 commits into
dsccommunity:masterfrom
JonasRied:Breaking/Issue#42
Open

BREAKING CHANGE: OfficeOnlineServerFarm: Added 'IsSingleInstance' parameter #65
JonasRied wants to merge 7 commits into
dsccommunity:masterfrom
JonasRied:Breaking/Issue#42

Conversation

@JonasRied

@JonasRied JonasRied commented Nov 6, 2023

Copy link
Copy Markdown
Contributor

Pull Request (PR) description

Adds the parameter 'IsSingleInstance' as suggested in #42.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@codecov

codecov Bot commented Nov 6, 2023

Copy link
Copy Markdown

Codecov Report

Merging #65 (24b9088) into master (7358992) will increase coverage by 0%.
The diff coverage is 98%.

Impacted file tree graph

@@         Coverage Diff          @@
##           master   #65   +/-   ##
====================================
  Coverage      80%   80%           
====================================
  Files           6     6           
  Lines         759   766    +7     
====================================
+ Hits          613   620    +7     
  Misses        146   146           
Files Coverage Δ
...eOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 95% <98%> (+<1%) ⬆️

@johlju johlju added the needs review The pull request needs a code review. label Nov 6, 2023
@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown

Walkthrough

The pull request introduces a new mandatory IsSingleInstance parameter to the OfficeOnlineServerFarm DSC resource and makes the InternalURL parameter optional. A new validation helper function ensures at least one URL (ExternalURL or InternalURL) is provided. The schema, module, examples, and tests are updated accordingly.

Changes

Cohort / File(s) Summary
Core Resource Implementation
src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1
Adds mandatory IsSingleInstance parameter (ValidateSet 'Yes') to Get-TargetResource, Set-TargetResource, and Test-TargetResource. Makes InternalURL optional. Introduces Test-OfficeOnlineServerFarmPSBoundParameters helper function for parameter validation. Strips IsSingleInstance from PSBoundParameters before Set-TargetResource processing.
Schema Definition
src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.schema.mof
Adds IsSingleInstance as a Key property with ValidateSet 'Yes'. Changes InternalURL from Key to Write property.
Documentation
CHANGELOG.md
Adds new OfficeOnlineServerFarm entry under Unreleased > Added with IsSingleInstance parameter.
Configuration Examples
src/Examples/FullExamples/NewFarm.ps1, src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1
Adds IsSingleInstance = 'Yes' property to OfficeOnlineServerFarm resource declarations in both example files.
Integration Tests
tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.config.ps1, tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.Integration.tests.ps1
Adds IsSingleInstance = 'Yes' to webAppsFarm hashtable and OfficeOnlineServerFarm resource. Renames Initialize-TestEnvironment parameter from -DSCResourceName to -DscResourceName. Adds pre-test cleanup to remove IsSingleInstance key from comparison hashtable.
Unit Tests
tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1
Adds IsSingleInstance = 'Yes' to mock hashtables. Updates Get-TargetResource calls to pass -IsSingleInstance parameter. Renames Invoke-TestSetup parameter from -DSCResourceName to -DscResourceName. Adds new test context validating that farm creation fails when both ExternalURL and InternalURL are absent. Adjusts parameter validation arrays and test assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: adding an 'IsSingleInstance' parameter to OfficeOnlineServerFarm as a breaking change.
Description check ✅ Passed The description is directly related to the changeset, explaining that it adds the IsSingleInstance parameter to resolve issue #42.
Linked Issues check ✅ Passed The PR successfully addresses issue #42 by making InternalURL optional and adding IsSingleInstance parameter, allowing external-only deployments as requested.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the IsSingleInstance parameter and making InternalURL optional; one parameter name change (DSCResourceName to DscResourceName) is a minor casing correction aligned with standards.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 (1)

810-821: ⚠️ Potential issue | 🟠 Major

Potential null reference when URL parameters are not provided.

The URL normalization code calls .EndsWith('/') on $InternalURL, $ExternalURL, and $Proxy without checking if they are null or empty. Since InternalURL is now optional, this will throw a MethodInvocationException when only ExternalURL is provided (and vice versa).

🐛 Proposed fix
-    if ($InternalURL.EndsWith('/') -eq $false)
+    if (-not [string]::IsNullOrEmpty($InternalURL) -and $InternalURL.EndsWith('/') -eq $false)
     {
         $InternalURL += "/"
     }
-    if ($ExternalURL.EndsWith('/') -eq $false)
+    if (-not [string]::IsNullOrEmpty($ExternalURL) -and $ExternalURL.EndsWith('/') -eq $false)
     {
         $ExternalURL += "/"
     }
-    if ($Proxy.EndsWith('/') -eq $false)
+    if (-not [string]::IsNullOrEmpty($Proxy) -and $Proxy.EndsWith('/') -eq $false)
     {
         $Proxy += "/"
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1`
around lines 810 - 821, The URL normalization block calls .EndsWith('/') on
potentially null/empty variables ($InternalURL, $ExternalURL, $Proxy) which can
throw MethodInvocationException; update the logic in
MSFT_OfficeOnlineServerFarm.psm1 to guard each variable with a null/empty check
(e.g. use -and and [string]::IsNullOrEmpty or an if (-not
[string]::IsNullOrEmpty($InternalURL)) before calling .EndsWith('/')) and only
append "/" when the variable is non-empty and does not already end with "/",
applying the same guarded checks for $ExternalURL and $Proxy.
🧹 Nitpick comments (5)
tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.Integration.tests.ps1 (1)

15-18: Parameter name casing inconsistency.

The parameter -DscResourceName uses different casing than other test files in the repository. Other unit tests (e.g., MSFT_OfficeOnlineServerInstall.tests.ps1) use -DSCResourceName for consistency.

📝 Suggested fix for consistency
 $TestEnvironment = Initialize-TestEnvironment `
     -DSCModuleName $Script:DSCModuleName `
-    -DscResourceName $Script:DSCResourceName `
+    -DSCResourceName $Script:DSCResourceName `
     -TestType Integration
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.Integration.tests.ps1`
around lines 15 - 18, The Initialize-TestEnvironment invocation uses
inconsistent parameter casing (-DscResourceName); update the call to use the
same casing as other tests by changing the parameter to -DSCResourceName so it
matches convention across the test suite (look for the
Initialize-TestEnvironment call and the -DscResourceName token to modify).
src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1 (1)

48-53: Inconsistent casing for IsSingleInstance value.

The value 'YES' differs from 'Yes' used in other examples (e.g., src/Examples/FullExamples/NewFarm.ps1). While PowerShell's ValidateSet is case-insensitive, using consistent casing improves readability and aligns with the schema definition.

📝 Suggested fix
     OfficeOnlineServerFarm LocalFarm
     {
-        IsSingleInstance = 'YES'
+        IsSingleInstance = 'Yes'
         InternalURL      = "https://officeonline.contoso.com"
         EditingEnabled   = $true
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1` around lines 48
- 53, The IsSingleInstance value in the OfficeOnlineServerFarm LocalFarm block
uses inconsistent casing ('YES'); update the IsSingleInstance property in the
OfficeOnlineServerFarm LocalFarm declaration to use 'Yes' to match other
examples (e.g., NewFarm.ps1) and the schema's preferred capitalization for
readability and consistency.
tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1 (2)

21-25: Parameter name casing inconsistency.

Same issue as the integration test - -DscResourceName differs from -DSCResourceName used in other test files.

📝 Suggested fix
     $script:testEnvironment = Initialize-TestEnvironment `
         -DSCModuleName $script:dscModuleName `
-        -DscResourceName $script:dscResourceName `
+        -DSCResourceName $script:dscResourceName `
         -ResourceType 'Mof' `
         -TestType 'Unit'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1`
around lines 21 - 25, The Initialize-TestEnvironment call uses a lowercase-cased
parameter name "-DscResourceName" which is inconsistent with other tests that
use "-DSCResourceName"; update the call so the parameter casing matches the
canonical form (use "-DSCResourceName") and ensure the referenced variable
($script:dscResourceName) remains the same, i.e., change only the parameter
token in the Initialize-TestEnvironment invocation to "-DSCResourceName" to
restore consistency across tests.

205-208: Replace deprecated Assert-MockCalled with Should -Invoke.

Per test guidelines, Assert-MockCalled is deprecated. This also applies to similar usages on lines 257 and 282.

📝 Suggested fix
                 It "Creates the farm in the set method" {
                     Set-TargetResource `@testParams`
-                    Assert-MockCalled New-OfficeWebAppsFarm
+                    Should -Invoke -CommandName New-OfficeWebAppsFarm -Exactly -Times 1 -Scope It
                 }

As per coding guidelines: "Never use Assert-MockCalled, use Should -Invoke instead".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1`
around lines 205 - 208, The test uses the deprecated Assert-MockCalled for
verifying New-OfficeWebAppsFarm after calling Set-TargetResource; replace the
Assert-MockCalled New-OfficeWebAppsFarm assertion with the modern invocation
assertion pattern using Should -Invoke (e.g. wrap the mocked command invocation
in a scriptblock and assert it was invoked: { New-OfficeWebAppsFarm } | Should
-Invoke), and make the same replacement for the other occurrences that assert
New-OfficeWebAppsFarm in this spec associated with Set-TargetResource.
CHANGELOG.md (1)

10-11: Consider adding issue reference to the changelog entry.

Per changelog guidelines, notable changes should reference issues. Since this PR fixes #42, consider updating the entry:

📝 Suggested improvement
 - OfficeOnlineServerFarm
-  - Added parameter 'IsSingleInstance'
+  - Added parameter 'IsSingleInstance' - Fixes [issue `#42`](https://github.com/dsccommunity/OfficeOnlineServerDsc/issues/42)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 10 - 11, Update the CHANGELOG entry for
OfficeOnlineServerFarm to reference the issue fixed by this PR by appending the
issue number to the entry for the added parameter 'IsSingleInstance' (for
example add "Fixes `#42`" or "(`#42`)") so the changelog follows the guidelines and
links the notable change to issue `#42`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1`:
- Around line 810-821: The URL normalization block calls .EndsWith('/') on
potentially null/empty variables ($InternalURL, $ExternalURL, $Proxy) which can
throw MethodInvocationException; update the logic in
MSFT_OfficeOnlineServerFarm.psm1 to guard each variable with a null/empty check
(e.g. use -and and [string]::IsNullOrEmpty or an if (-not
[string]::IsNullOrEmpty($InternalURL)) before calling .EndsWith('/')) and only
append "/" when the variable is non-empty and does not already end with "/",
applying the same guarded checks for $ExternalURL and $Proxy.

---

Nitpick comments:
In `@CHANGELOG.md`:
- Around line 10-11: Update the CHANGELOG entry for OfficeOnlineServerFarm to
reference the issue fixed by this PR by appending the issue number to the entry
for the added parameter 'IsSingleInstance' (for example add "Fixes `#42`" or
"(`#42`)") so the changelog follows the guidelines and links the notable change to
issue `#42`.

In `@src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1`:
- Around line 48-53: The IsSingleInstance value in the OfficeOnlineServerFarm
LocalFarm block uses inconsistent casing ('YES'); update the IsSingleInstance
property in the OfficeOnlineServerFarm LocalFarm declaration to use 'Yes' to
match other examples (e.g., NewFarm.ps1) and the schema's preferred
capitalization for readability and consistency.

In `@tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.Integration.tests.ps1`:
- Around line 15-18: The Initialize-TestEnvironment invocation uses inconsistent
parameter casing (-DscResourceName); update the call to use the same casing as
other tests by changing the parameter to -DSCResourceName so it matches
convention across the test suite (look for the Initialize-TestEnvironment call
and the -DscResourceName token to modify).

In `@tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1`:
- Around line 21-25: The Initialize-TestEnvironment call uses a lowercase-cased
parameter name "-DscResourceName" which is inconsistent with other tests that
use "-DSCResourceName"; update the call so the parameter casing matches the
canonical form (use "-DSCResourceName") and ensure the referenced variable
($script:dscResourceName) remains the same, i.e., change only the parameter
token in the Initialize-TestEnvironment invocation to "-DSCResourceName" to
restore consistency across tests.
- Around line 205-208: The test uses the deprecated Assert-MockCalled for
verifying New-OfficeWebAppsFarm after calling Set-TargetResource; replace the
Assert-MockCalled New-OfficeWebAppsFarm assertion with the modern invocation
assertion pattern using Should -Invoke (e.g. wrap the mocked command invocation
in a scriptblock and assert it was invoked: { New-OfficeWebAppsFarm } | Should
-Invoke), and make the same replacement for the other occurrences that assert
New-OfficeWebAppsFarm in this spec associated with Set-TargetResource.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80b5bc84-aa75-4d76-bba9-ab894b1bcd34

📥 Commits

Reviewing files that changed from the base of the PR and between 6b6ce1f and 00d6ee7.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1
  • src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.schema.mof
  • src/Examples/FullExamples/NewFarm.ps1
  • src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1
  • tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.Integration.tests.ps1
  • tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.config.ps1
  • tests/Unit/OfficeOnlineserverDSC/MSFT_OfficeOnlineServerFarm.tests.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review The pull request needs a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OfficeOnlineServerFarm: InternalURL should not be mandatory

3 participants