Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anmenaga committed Aug 28, 2024
2 parents d0cbc72 + dc78c0c commit a920781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
9 changes: 4 additions & 5 deletions powershell-adapter/psDscAdapter/psDscAdapter.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ function Get-DscResourceObject {

# catch potential for improperly formatted configuration input
if ($inputObj.resources -and -not $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
'WARNING: The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace
'The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace -Operation Warn
}

$adapterName = 'Microsoft.DSC/PowerShell'
Expand Down Expand Up @@ -486,12 +486,12 @@ function Invoke-DscOperation {
}
catch {

'ERROR: ' + $_.Exception.Message | Write-DscTrace
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
exit 1
}
}
Default {
'Resource ImplementationDetail not supported: ' + $cachedDscResourceInfo.ImplementationDetail | Write-DscTrace
'Resource ImplementationDetail not supported: ' + $cachedDscResourceInfo.ImplementationDetail | Write-DscTrace -Operation Error
exit 1
}
}
Expand All @@ -500,8 +500,7 @@ function Invoke-DscOperation {
}
else {
$dsJSON = $DesiredState | ConvertTo-Json -Depth 10
$errmsg = 'Can not find type "' + $DesiredState.type + '" for resource "' + $dsJSON + '". Please ensure that Get-DscResource returns this resource type.'
'ERROR: ' + $errmsg | Write-DscTrace
'Can not find type "' + $DesiredState.type + '" for resource "' + $dsJSON + '". Please ensure that Get-DscResource returns this resource type.' | Write-DscTrace -Operation Error
exit 1
}
}
Expand Down
17 changes: 8 additions & 9 deletions powershell-adapter/psDscAdapter/win_psDscAdapter.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ else {
$env:PSModulePath += ";$env:windir\System32\WindowsPowerShell\v1.0\Modules"
$PSDesiredStateConfiguration = Import-Module -Name 'PSDesiredStateConfiguration' -RequiredVersion '1.1' -Force -PassThru -ErrorAction stop -ErrorVariable $importModuleError
if (-not [string]::IsNullOrEmpty($importModuleError)) {
'ERROR: Could not import PSDesiredStateConfiguration 1.1 in Windows PowerShell. ' + $importModuleError | Write-DscTrace
'Could not import PSDesiredStateConfiguration 1.1 in Windows PowerShell. ' + $importModuleError | Write-DscTrace -Operation Error
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ function Invoke-DscCacheRefresh {
if ( $psdscVersion -ge '2.0.7' ) {
# only support known dscResourceType
if ([dscResourceType].GetEnumNames() -notcontains $dscResource.ImplementationDetail) {
'WARNING: implementation detail not found: ' + $dscResource.ImplementationDetail | Write-DscTrace
'Implementation detail not found: ' + $dscResource.ImplementationDetail | Write-DscTrace -Operation Warn
continue
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ function Get-DscResourceObject {

# catch potential for improperly formatted configuration input
if ($inputObj.resources -and -not $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
'WARNING: The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace
'The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace -Operation Warn
}

# match adapter to version of powershell
Expand Down Expand Up @@ -338,7 +338,7 @@ function Invoke-DscOperation {

# For Linux/MacOS, only class based resources are supported and are called directly.
if ($IsLinux) {
'ERROR: Script based resources are only supported on Windows.' | Write-DscTrace
'Script based resources are only supported on Windows.' | Write-DscTrace -Operation Error
exit 1
}

Expand Down Expand Up @@ -374,7 +374,7 @@ function Invoke-DscOperation {
$addToActualState.properties = $ResultProperties
}
catch {
'ERROR: ' + $_.Exception.Message | Write-DscTrace
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
exit 1
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@ function Invoke-DscOperation {
}
catch {

'ERROR: ' + $_.Exception.Message | Write-DscTrace
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
exit 1
}
}
Expand Down Expand Up @@ -445,7 +445,7 @@ function Invoke-DscOperation {
$addToActualState.properties = $ResultProperties
}
catch {
'ERROR: ' + $_.Exception.Message | Write-DscTrace
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
exit 1
}
}
Expand All @@ -459,8 +459,7 @@ function Invoke-DscOperation {
}
else {
$dsJSON = $DesiredState | ConvertTo-Json -Depth 10
$errmsg = 'Can not find type "' + $DesiredState.type + '" for resource "' + $dsJSON + '". Please ensure that Get-DscResource returns this resource type.'
'ERROR: ' + $errmsg | Write-DscTrace
'Can not find type "' + $DesiredState.type + '" for resource "' + $dsJSON + '". Please ensure that Get-DscResource returns this resource type.' | Write-DscTrace -Operation Error
exit 1
}
}
Expand Down

0 comments on commit a920781

Please sign in to comment.