puppetlabs / Puppet.Dsc

Convert DSC resources into Puppet Resource API types and providers
https://www.powershellgallery.com/packages/Puppet.Dsc
Apache License 2.0
9 stars 12 forks source link

dsc_timezone has incorrect dscmeta_resource_implementation #241

Open ShawnHardwick opened 1 year ago

ShawnHardwick commented 1 year ago

Describe the Bug

dsc_timezone resource in dsc-computermanagementdsc (8.5.0-0-1) is defined as Class instead of MOF for dscmeta_resource_implementation.

Using the implementation for Get-DSCResourceImplementation: https://github.com/puppetlabs/Puppet.Dsc/blob/main/src/Puppet.Dsc/internal/functions/Get-DscResourceImplementation.ps1#L92

# Returns 'Class'
using module 'C:\ProgramData\PuppetLabs\puppet\cache\lib\puppet_x\computermanagementdsc\dsc_resources\ComputerManagementDsc\DSCResources\DSC_TimeZone\DSC_TimeZone.psm1'
Try {
  $ErrorActionPreference = 'Stop'
  $null = [TimeZone]
  'Class'
} Catch {
  'MOF'
}

What does [TimeZone] actually return?

using module 'C:\ProgramData\PuppetLabs\puppet\cache\lib\puppet_x\computermanagementdsc\dsc_resources\ComputerManagementDsc\DSCResources\DSC_TimeZone\DSC_TimeZone.psm1'
[TimeZone] | fl *

Output:

# Truncated for brevity
Module                     : CommonLanguageRuntimeLibrary
Assembly                   : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
TypeHandle                 : System.RuntimeTypeHandle
DeclaringMethod            :
BaseType                   : System.Object
UnderlyingSystemType       : System.TimeZone
FullName                   : System.TimeZone
AssemblyQualifiedName      : System.TimeZone, mscorlib, Version=4.0.0.0, Culture=neutral,
                             PublicKeyToken=b77a5c561934e089
Namespace                  : System
StructLayoutAttribute      : System.Runtime.InteropServices.StructLayoutAttribute
Name                       : TimeZone
MemberType                 : TypeInfo

Additional Context

Add any other context about the problem here.

GSPatton commented 1 year ago

hi @ShawnHardwick, thanks for raising this. Is this bug still present in the 9.0.0 release? http://forge.puppet.com/modules/dsc/computermanagementdsc/

ShawnHardwick commented 1 year ago

Yes it is still an issue as far as I know.

# From 9.0.0-0-0 release of dsc-computermanagementdsc
Puppet::ResourceApi.register_type(
  name: 'dsc_timezone',
  dscmeta_resource_friendly_name: 'TimeZone',
  dscmeta_resource_name: 'DSC_TimeZone',
  dscmeta_resource_implementation: 'Class',
  dscmeta_module_name: 'ComputerManagementDsc',
  dscmeta_module_version: '9.0.0',
  docs: 'The DSC TimeZone resource type.
         Automatically generated from version 9.0.0',

dsc_meta_resource_implementation is derived from https://github.com/puppetlabs/Puppet.Dsc/blob/main/src/Puppet.Dsc/internal/functions/Get-DscResourceImplementation.ps1#L92

The crux of the issue is that $null = [TimeZone] will pull types from the Global Assembly Cache (GAC) which has the TimeZone namespace defined. I could be wrong, but I would expect this to be a MOF resource, not a Class resource.