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

Get-SqlDscAudit: Name no longer mandatory #1850

Merged
merged 13 commits into from
Mar 7, 2023

Conversation

johlju
Copy link
Member

@johlju johlju commented Feb 11, 2023

Pull Request (PR) description

  • Get-SqlDscAudit
    • The parameter Name is no longer mandatory. When left out all the current
      audits are returned.

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 updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju added the needs review The pull request needs a code review. label Feb 11, 2023
@codecov
Copy link

codecov bot commented Feb 11, 2023

Codecov Report

Merging #1850 (5010c28) into main (e65a410) will increase coverage by 0%.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #1850   +/-   ##
====================================
  Coverage    92%     92%           
====================================
  Files        85      85           
  Lines      7614    7623    +9     
====================================
+ Hits       7012    7021    +9     
  Misses      602     602           
Flag Coverage Δ
unit 92% <100%> (+<1%) ⬆️
Impacted Files Coverage Δ
source/Classes/020.SqlAudit.ps1 99% <100%> (+<1%) ⬆️
source/Public/Disable-SqlDscAudit.ps1 100% <100%> (ø)
source/Public/Enable-SqlDscAudit.ps1 100% <100%> (ø)
source/Public/Get-SqlDscAudit.ps1 93% <100%> (+1%) ⬆️
source/Public/New-SqlDscAudit.ps1 100% <100%> (ø)
source/Public/Remove-SqlDscAudit.ps1 100% <100%> (ø)
source/Public/Set-SqlDscAudit.ps1 100% <100%> (ø)

Copy link
Member Author

@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.

Reviewed 9 of 9 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions


source/Classes/020.SqlAudit.ps1 line 263 at r1 (raw file):

        $serverObject = $this.GetServerObject()

        $auditObject = $serverObject |

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

        $auditObject = $serverObject |
            Get-SqlDscAudit -Name $properties.Name -ErrorAction 'SilentlyContinue' |
            Select-Object -First 1

source/Classes/020.SqlAudit.ps1 line 353 at r1 (raw file):

            if ($this.Ensure -eq [Ensure]::Present)
            {
                $auditObject = $serverObject |

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

                $auditObject = $serverObject |
                    Get-SqlDscAudit -Name $this.Name -ErrorAction 'Stop' |
                    Select-Object -First 1

source/Public/Disable-SqlDscAudit.ps1 line 89 at r1 (raw file):

            # If this command does not find the audit it will throw an exception.
            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |
                Select-Object -First 1

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |
                Select-Object -First 1

source/Public/Enable-SqlDscAudit.ps1 line 88 at r1 (raw file):

            # If this command does not find the audit it will throw an exception.
            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |
                Select-Object -First 1

source/Public/New-SqlDscAudit.ps1 line 217 at r1 (raw file):

        }

        $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters |

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

        $auditObject = Get-SqlDscAudit @getSqlDscAuditParameters |
            Select-Object -First 1

source/Public/Set-SqlDscAudit.ps1 line 262 at r1 (raw file):

            }

            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Code quote:

            $AuditObject = Get-SqlDscAudit @getSqlDscAuditParameters |
                Select-Object -First 1

Copy link
Member Author

@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.

Reviewed all commit messages.
Reviewable status: 4 of 9 files reviewed, all discussions resolved (waiting on @johlju)


source/Classes/020.SqlAudit.ps1 line 263 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done


source/Classes/020.SqlAudit.ps1 line 353 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done


source/Public/Disable-SqlDscAudit.ps1 line 89 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done


source/Public/Enable-SqlDscAudit.ps1 line 88 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done


source/Public/New-SqlDscAudit.ps1 line 217 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done


source/Public/Set-SqlDscAudit.ps1 line 262 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

To avoid a potential problem with wrong type is returned, make the same workaround as in Remove-SqlDscAudit.

            # If this command does not find the audit it will throw an exception.
            $auditObjectArray = Get-SqlDscAudit @getSqlDscAuditParameters

            # Pick the only object in the array.
            $AuditObject = $auditObjectArray | Select-Object -First 1

Done

Copy link
Member Author

@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.

:lgtm:

Reviewed 5 of 5 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju)

@johlju johlju merged commit 54b66c6 into dsccommunity:main Mar 7, 2023
@johlju johlju deleted the fix/issue#1812 branch March 7, 2023 17:48
@johlju johlju removed the needs review The pull request needs a code review. label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get-SqlDscAudit: Should not enforce to use parameter Name
1 participant