-
Notifications
You must be signed in to change notification settings - Fork 149
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
xIisMimeTypeMapping: Make ConfigurationPath a non-mandatory parameter #577
Comments
This property needs to be mandatory and a key in the schema, otherwise it wouldn't be possible to have this configuration. xIisMimeTypeMapping Mpeg
{
Ensure = 'Present'
Extension = '.mpeg'
MimeType = 'video/mpeg'
ConfigurationPath = "IIS:\sites\Site1"
}
xIisMimeTypeMapping Mpeg
{
Ensure = 'Present'
Extension = '.mpeg'
MimeType = 'video/mpeg'
ConfigurationPath = "IIS:\sites\Site2"
} I think instead the default values (the constants) should be removed. 🤔 |
I'm not saying to remove the value or parameter as I know you need to pass something to the backend functions but making the parameter non-mandatory would allow you to pick up the default server-wide ConfigurationPath and still allow you to override using the config you posted. But yeah I guess you could go the other direction and keep it mandatory and then remove the unnecessary checks for a empty variables. I'm not too sure what the best practices are in terms of DSC resources and default values (in normal modules it's widely accepted to set default values in the param blocks) but for me, I didn't know what I needed to pass in to the |
Ah I just realised I glossed over your point I'm pretty new to DSC so I'm not too sure about how DSC schemas are implemented and used and didn't even look in the schema file until you mentioned it lol So I guess those keys are what define the uniqueness of the DSC resources for want of a better phrase? In that case I understand why it would be a required property. |
Yes exactly. You are correct that the properties that have the type Key define uniqueness. It cannot exist two resource instances with the same values for those parameters in the same configuration to be able to enforce the desired state. Mandatory parameter can for that reason not have default values. There are four possible types of type qualifiers in the schema; Key, Required, Write, and Read. |
Details of the scenario you tried and the problem that is occurring
I tried to use the
xIisMimeTypeMapping
resource without specifying theConfigurationPath
parameter as it wasn't listed as a property in the repositoryreadme.md
file. I then got an error saying that I was missing a mandatory parameterConfigurationPath
. After looking at the source code there is already a default value defined for this parameter if it's not specified here so it's unnecessary for the parameter to be mandatory.Verbose logs showing the problem
N/A
Suggested solution to the issue
In the MSFT_xIisMimeTypeMapping.psm1 file change lines 35, 107 and 181 from
[Parameter(Mandatory = $true)]
to[Parameter()]
so that the parameter is not mandatory and will use theMACHINE/WEBROOT/APPHOST
default value if not specified.There should also be an update to the
readme.md
file to reference this parameter.The DSC configuration that is used to reproduce the issue (as detailed as possible)
N/A
The operating system the target node is running
N/A
Version and build of PowerShell the target node is running
N/A
Version of the DSC module that was used
3.1.1
The text was updated successfully, but these errors were encountered: