Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfficeOnlineServerHost: New resource proposal #66

Conversation

JonasCassier
Copy link
Contributor

@JonasCassier JonasCassier commented Nov 9, 2023

Pull Request (PR) description

Adds new resource OfficeOnlineServerHost
Replacement of #63

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

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Merging #66 (60df501) into master (7358992) will increase coverage by 0%.
Report is 2 commits behind head on master.
The diff coverage is 92%.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           master   #66   +/-   ##
====================================
  Coverage      80%   81%           
====================================
  Files           6     7    +1     
  Lines         759   804   +45     
====================================
+ Hits          613   657   +44     
- Misses        146   147    +1     
Files Coverage Δ
...eServerInstall/MSFT_OfficeOnlineServerInstall.psm1 84% <100%> (ø)
...ck/MSFT_OfficeOnlineServerInstallLanguagePack.psm1 88% <100%> (ø)
...eServerMachine/MSFT_OfficeOnlineServerMachine.psm1 98% <100%> (ø)
...ctUpdate/MSFT_OfficeOnlineServerProductUpdate.psm1 77% <100%> (ø)
...eOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 95% <98%> (ø)
...eOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 94% <94%> (ø)
...lineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1 57% <0%> (-2%) ⬇️

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

This is what I had time for today. Barely started with the review, but now there are a few things for you to look over. 🙂

Reviewed 1 of 10 files at r1, all commit messages.
Reviewable status: 1 of 10 files reviewed, 8 unresolved discussions (waiting on @JonasCassier)


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 42 at r2 (raw file):

    Test-OfficeOnlineServerHostPSBoundParameters @PSBoundParameters

    $nullReturn = $PSBoundParameters

SUggest using @{} + $PSBoundParameters so when get a new hashtable, otherwise we just get the ref of a type System.Management.Automation.PSBoundParametersDictionary (which is not a hashtable which we should return) and also, any changes made to the variable (in a future PR) will also change the values of PSBoundParameters since we get a ref to the type PSBoundParametersDictionary.


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 43 at r2 (raw file):

    $nullReturn = $PSBoundParameters
    $nullReturn.Domains = @()

Should this also be set to the type [System.Array] so we consequent (it is set to the type below in another code path).


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 45 at r2 (raw file):

    $nullReturn.Domains = @()

    try

The try-catch should only be around the command that we catch, so that we can catch errors and throw for things that should be terminating errors (those can be set in a future PR. But here I would rather not see we use try-catch to switch code path. I rather see that the catch-statement sets a boolean value that we evaluate to determine if we could access the needed property, then return a hashtable accordingly.


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 47 at r2 (raw file):

    try
    {
        return @{

We should always return all properties in the hashtable (as null or the value passed if they cannot be set to a current configured value).


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 49 at r2 (raw file):

        return @{
            IsSingleInstance = 'Yes'
            Domains          = [Array](Get-OfficeWebAppsHost -ErrorAction 'Stop').AllowList

We shuould use the full type name [System.Array].


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 70 at r2 (raw file):

        [Parameter()]
        [System.String[]]
        $Domains,

Thw parameter Domains should be mutually exclusive to DomainsToInclude and DomainsToExclude. All three should not be allowed to be used at once., Only DomainsToInclude and DomainsToExclude should be bale to be used at the same time.

There is a command Assert-BoundParameter in the module DscResource.Common that can help with this. Though I see this module does not use the helper module (yet). There is a blog post on how to add the helper module to a DSC module, though this might break other modules that need to be fixed, so I think that should be done in a separate PR. So another option is to copy the code from DscResource.Common and put it in # OfficeOnlineServerDsc.Util. 🤔 You decide 😃


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 81 at r2 (raw file):

    )

    Write-Verbose -Message "Updating Office Online Server Farm host allow list"

Can we move the strings to the localization files? Throughout the code. Then use them similar to here:

Write-Verbose -Message $script:localizedData.InstallingNewFarm


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 96 at r2 (raw file):

        if ($null -eq $Domains)
        {
            $PSBoundParameters.Add('DomainsToExclude', $CurrentValues.Domains) | Out-Null

See previous comment about $PSBoundParameters. We should not add properties to the $PSBoundParameters because then we cannot determine if they were actually passed by the user/configuration. Suggest using a new hashtable here to control the flow.

@johlju johlju added the waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. label Nov 11, 2023
Copy link
Contributor Author

@JonasCassier JonasCassier left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 10 files reviewed, 8 unresolved discussions (waiting on @johlju)


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 43 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Should this also be set to the type [System.Array] so we consequent (it is set to the type below in another code path).

I don't quite understand what you mean by that. @() is of type [System.Array]. Or do you mean something like [System.Array]@()?


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 49 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

We shuould use the full type name [System.Array].

Done.


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 81 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Can we move the strings to the localization files? Throughout the code. Then use them similar to here:

Write-Verbose -Message $script:localizedData.InstallingNewFarm

Done.


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 96 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

See previous comment about $PSBoundParameters. We should not add properties to the $PSBoundParameters because then we cannot determine if they were actually passed by the user/configuration. Suggest using a new hashtable here to control the flow.

Done.

Copy link
Contributor Author

@JonasCassier JonasCassier left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 10 files reviewed, 8 unresolved discussions (waiting on @johlju)


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 70 at r2 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Thw parameter Domains should be mutually exclusive to DomainsToInclude and DomainsToExclude. All three should not be allowed to be used at once., Only DomainsToInclude and DomainsToExclude should be bale to be used at the same time.

There is a command Assert-BoundParameter in the module DscResource.Common that can help with this. Though I see this module does not use the helper module (yet). There is a blog post on how to add the helper module to a DSC module, though this might break other modules that need to be fixed, so I think that should be done in a separate PR. So another option is to copy the code from DscResource.Common and put it in # OfficeOnlineServerDsc.Util. 🤔 You decide 😃

I use Test-OfficeOnlineServerHostPSBoundParameters for this. I suggest to proceed with this function first and in a second PR I try to import 'DSCResource.Common'. Okay?

Copy link
Contributor Author

@JonasCassier JonasCassier left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 10 files reviewed, 8 unresolved discussions (waiting on @johlju)


src/DSCResources/MSFT_OfficeOnlineServerHost/MSFT_OfficeOnlineServerHost.psm1 line 70 at r2 (raw file):

Previously, JonasCassier (Jonas Cassier) wrote…

I use Test-OfficeOnlineServerHostPSBoundParameters for this. I suggest to proceed with this function first and in a second PR I try to import 'DSCResource.Common'. Okay?

I have created another PR #68 to import DscResource.Common into this project. Maybe we can merge that PR first?

@johlju
Copy link
Member

johlju commented Nov 19, 2023

The other PR is merged so we can rebase this and use the commands from the common module! 🙂

@JonasCassier
Copy link
Contributor Author

@johlju I have included the functions from DSCResource.Common in this resource. But I have no idea what I am doing wrong with git rebase. I have synchronized my fork JonasCassier/OfficeOnlineServerDsc:master with dsccommunity/OfficeOnlineServerDsc:master. Then I rebased Feature/OfficeOnlineServerHost with my master. And now we have the same mess as last time :(.

@johlju johlju added duplicate The issue or PR is the duplicate of another. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The issue or PR is the duplicate of another.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OfficeOnlineServerHost: New resource proposal
2 participants