From 0738053fc0d35327bab7bb50d4f6f1a7e00760bd Mon Sep 17 00:00:00 2001 From: wahid alam Date: Mon, 4 Jul 2022 17:53:02 +0100 Subject: [PATCH] SqlPermission: Permission parameter should be mandatory --- CHANGELOG.md | 3 +++ .../DSCResources/DSC_SqlPermission/DSC_SqlPermission.psm1 | 6 +++--- .../DSC_SqlPermission/DSC_SqlPermission.schema.mof | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ab36284d..46f1d536c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -178,6 +178,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 the maximum memory is not specified. - In a certain scenario the maximum memory would be enforced even if it was not specified in the configuration. +- SqlPermission + - The `Permission` parameter is now mandatory for all `*-TargetResource` + ([issue #1761](https://github.com/dsccommunity/SqlServerDsc/issues/1761)). - SqlWindowsFirewall - Now the variables in `Get-TargetResource` are correctly initialized so they pass the new unit test that use strict mode. diff --git a/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.psm1 b/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.psm1 index 97803806f..4aa28008d 100644 --- a/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.psm1 +++ b/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.psm1 @@ -41,7 +41,7 @@ function Get-TargetResource [System.String] $Principal, - [Parameter()] + [Parameter(Mandatory = $true)] [ValidateSet('ConnectSql', 'AlterAnyAvailabilityGroup', 'ViewServerState', 'AlterAnyEndPoint')] [System.String[]] $Permission @@ -140,7 +140,7 @@ function Set-TargetResource [System.String] $Principal, - [Parameter()] + [Parameter(Mandatory = $true)] [ValidateSet('ConnectSql', 'AlterAnyAvailabilityGroup', 'ViewServerState', 'AlterAnyEndPoint')] [System.String[]] $Permission @@ -238,7 +238,7 @@ function Test-TargetResource [System.String] $Principal, - [Parameter()] + [Parameter(Mandatory = $true)] [ValidateSet('ConnectSql', 'AlterAnyAvailabilityGroup', 'ViewServerState', 'AlterAnyEndPoint')] [System.String[]] $Permission diff --git a/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.schema.mof b/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.schema.mof index ccc9d238d..2b900c493 100644 --- a/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.schema.mof +++ b/source/DSCResources/DSC_SqlPermission/DSC_SqlPermission.schema.mof @@ -5,5 +5,5 @@ class DSC_SqlPermission : OMI_BaseResource [Write, Description("The host name of the _SQL Server_ to be configured. Default value is the current computer name.")] String ServerName; [Write, Description("If the permission should be present or absent. Default value is `'Present'`."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Key, Description("The login to which permission will be set.")] String Principal; - [Write, Description("The permission to set for the login."), ValueMap{"ConnectSql","AlterAnyAvailabilityGroup","ViewServerState","AlterAnyEndPoint"}, Values{"ConnectSql","AlterAnyAvailabilityGroup","ViewServerState","AlterAnyEndPoint"}] String Permission[]; + [Required, Description("The permission to set for the login."), ValueMap{"ConnectSql","AlterAnyAvailabilityGroup","ViewServerState","AlterAnyEndPoint"}, Values{"ConnectSql","AlterAnyAvailabilityGroup","ViewServerState","AlterAnyEndPoint"}] String Permission[]; };