Skip to content

Commit 33b0568

Browse files
authored
ver.0.110
Fixed bug #260 & added new unit test
2 parents 09fc6e4 + 26f8fdd commit 33b0568

File tree

8 files changed

+105
-8
lines changed

8 files changed

+105
-8
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "ADF-BIGroupFacts01-Dev",
3+
"properties": {
4+
"globalConfigurations": {
5+
"PipelineBillingEnabled": "false"
6+
}
7+
},
8+
"location": "eastus"
9+
}

adhoc/issue-260/repro_code.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Import-Module ".\azure.datafactory.tools.psd1" -Force
2+
#Get-Module
3+
$ErrorActionPreference = 'Stop'
4+
$VerbosePreference = 'Continue'
5+
$DebugPreference = 'Continue'
6+
7+
. .\adhoc\~~Load-all-cmdlets-locally.ps1 # Load to this session
8+
9+
$path = (.\adhoc\Get-RootPath.ps1)
10+
#$RootFolder = Join-Path $path 'ADF-BIGroupFacts01-Dev'
11+
#$RootFolder = "$path\test\BigFactorySample2"
12+
$RootFolder = Join-Path $path 'AzureADF'
13+
$ConfigFolder = Join-Path $RootFolder 'deployment'
14+
15+
# Test
16+
Test-AdfCode -RootFolder $RootFolder -ConfigPath $ConfigFolder
17+
18+
19+
20+
# Investigation
21+
$adfName = Split-Path -Path "$RootFolder" -Leaf
22+
$adf = Import-AdfFromFolder -FactoryName "$adfName" -RootFolder "$RootFolder" -ErrorAction "SilentlyContinue"
23+
24+
$adf.GlobalFactory.GlobalParameters
25+
26+
#--if ($adf.Factories.Count -gt 0 -and (Get-Member -InputObject $adf.Factories[0].Body -name "properties" -Membertype "Properties")) {
27+
Get-Member -InputObject $adf.Factories[0].Body.properties.globalParameters -Membertype "NoteProperty"
28+
$adf.GlobalFactory
29+
30+
# StrictMode & function
31+
32+
function test-something {
33+
Write-Host "check-some"
34+
Set-StrictMode -Version 1
35+
$adf.Factories[0].Body.properties.globalParameters
36+
}
37+
38+
Set-StrictMode -Version 3
39+
test-something
40+
Write-Host "root code:"
41+
$gparams = $adf.Factories[0].Body.properties.globalParameters
42+
if ($gparams)
43+
{
44+
Get-Member -InputObject $adf.Factories[0].Body.properties.globalParameters -Membertype "NoteProperty"
45+
}
46+

azure.datafactory.tools.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Kamil Nowinski @ SQLPlayer.net
55
#
6-
# Generated on: 19/11/2022
6+
# Generated on: 02/12/2022
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'azure.datafactory.tools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.101.0'
15+
ModuleVersion = '0.110.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [0.110.0] - 2022-12-02
8+
### Fixed
9+
* Bug #260: Test-AdfCode function: The property 'globalParameters' cannot be found on this object.
10+
711
## [0.101.0] - 2022-11-19
812
### Fixed
913
* Bug #226: Cannot overwrite/set DateTime type of value via config file

private/Import-AdfObjects.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ function Import-AdfObjects {
2727
$o.FileName = $_.FullName
2828
$o.Body = $txt | ConvertFrom-Json
2929

30+
# Set Global Parameters
31+
if ($SubFolder -eq 'factory') {
32+
$adf.GlobalFactory.FilePath = $_.FullName
33+
$adf.GlobalFactory.body = $txt
34+
Set-StrictMode -Version 1
35+
$adf.GlobalFactory.GlobalParameters = $o.Body.Properties.globalParameters
36+
}
37+
3038
# Discover all referenced objects
3139
$refs = Get-ReferencedObjects -obj $o
3240
foreach ($r in $refs) {

public/Test-AdfCode.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function Test-AdfCode {
7676

7777
Write-Host "=== Validating other rules ..."
7878

79+
Write-Host "Checking duplicated names..."
7980
$adf.AllObjects().Name | Sort-Object -Unique | ForEach-Object {
8081
$r = $adf.GetObjectsByFullName("*." + $_)
8182
if ($r.Count -gt 1) {
@@ -84,6 +85,7 @@ function Test-AdfCode {
8485
}
8586
}
8687

88+
Write-Host "Checking names of datasets, pipelines, dataflows..."
8789
$adf.LinkedServices + $adf.DataSets + $adf.Pipelines + $adf.DataFlows | ForEach-Object {
8890
[string] $name = $_.Name
8991
if ($name.Contains('-')) {
@@ -92,12 +94,16 @@ function Test-AdfCode {
9294
}
9395
}
9496

95-
if ($adf.Factories.Count -gt 0 -and (Get-Member -InputObject $adf.Factories[0].Body -name "properties" -Membertype "Properties")) {
96-
Get-Member -InputObject $adf.Factories[0].Body.properties.globalParameters -Membertype "NoteProperty" | ForEach-Object {
97-
[string] $name = $_.Name
98-
if ($name.Contains('-')) {
99-
Write-Warning "Dashes ('-') are not allowed in the names of global parameters ($name)."
100-
$result.WarningCount += 1
97+
Write-Host "Checking: Global parameter names..."
98+
if ($adf.Factories.Count -gt 0) {
99+
$gparams = $adf.GlobalFactory.GlobalParameters
100+
if ($gparams) {
101+
$gparams | ForEach-Object {
102+
[string] $name = $_.Name
103+
if ($name.Contains('-')) {
104+
Write-Warning "Dashes ('-') are not allowed in the names of global parameters ($name)."
105+
$result.WarningCount += 1
106+
}
101107
}
102108
}
103109
}
@@ -118,6 +124,7 @@ function Test-AdfCode {
118124
$files | ForEach-Object {
119125
try {
120126
$FileName = $_.FullName
127+
Write-Host "Checking config file: $FileName..."
121128
Update-PropertiesFromFile -adf $adf -stage $FileName -ErrorVariable err -ErrorAction 'Stop' -dryRun:$True
122129
}
123130
catch {

test/Test-AdfCode.Tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ InModuleScope azure.datafactory.tools {
3535
$res.ErrorCount | Should -Be 1
3636
$res.WarningCount | Should -Be 6
3737
}
38+
}
39+
3840

41+
Describe 'Test-AdfCode' -Tag 'Unit' {
42+
It 'Should not throw error when factory has no GP but other global config' {
43+
$DataFactoryName = "adf3"
44+
$RootFolder = Join-Path -Path $PSScriptRoot -ChildPath $DataFactoryName
45+
{
46+
$script:res = Test-AdfCode -RootFolder $RootFolder
47+
} | Should -Not -Throw
48+
}
3949
}
50+
51+
52+
53+
4054
}

test/adf3/factory/adf3.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "adf3",
3+
"properties": {
4+
"globalConfigurations": {
5+
"PipelineBillingEnabled": "false"
6+
}
7+
},
8+
"location": "eastus"
9+
}

0 commit comments

Comments
 (0)