Skip to content

Commit 11b205e

Browse files
authored
Merge pull request #73 from SQLPlayer/develop
ver.0.19
2 parents ea303fb + 3688efa commit 11b205e

35 files changed

+768
-279
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,16 @@ Therefore you can use the following combinations:
217217
```
218218
trigger.*
219219
dataset.DS_*
220-
*.PL_*
220+
*.PL_*@test*
221221
linkedService.???KeyVault*
222222
pipeline.ScdType[123]
223+
trigger.*@testFolder
223224
```
224-
Full name of objects supported by the module is built of: `{Type}.{Name}`
225+
Full name of objects supported by the module is built of: `{Type}.{Name}@{Folder}`
225226
All potential combinations can be found in code repository of ADF:
226227
*Type* - name of folder
227-
*Name* - name of file (without JSON extension)
228+
*Name* - name of file (without JSON extension)
229+
*Folder* - name of (ADF) folder to which objects belong to
228230

229231
> More info about wildcard: [About Wildcard](https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-5.1)
230232

azure.datafactory.tools.psd1

0 Bytes
Binary file not shown.

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ 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.19.0] - 2020-12-23
8+
### Added
9+
* Support wildcard when specifying object(s) name in config file (#58)
10+
* Added option $IgnoreLackOfReferencedObject (#64)
11+
* Add object name to the msg before action (#49)
12+
* Exit publish cmd when ADF name is already in use (#43)
13+
* Allow selecting objects in given folder (#68)
14+
### Fixed
15+
* Finding dependencies miss objects when the same object names occurs (#65)
16+
* DeleteNotInSource fails when attempting to remove active trigger or found many dependant objects (#67)
717

818
## [0.18.0] - 2020-12-04
919
### Added

en-us/messages_index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Messages:
2+
ADFTmxxx
3+
m = module/feature
4+
0 - Generic
5+
6+
xxx - number of error
7+
8+
## Index
9+
ADFT0005: Referenced object [$name] was not found.
10+
ADFT0006: Referenced object [$name] was not found. No error raised as user wanted to carry on.
11+
12+
ADFT0007: Could not find object: $type.$name
13+
ADFT0008: Could not find object: $type.$name
14+
ADFT0009: Body of the object is empty!
15+
ADFT0010: Wrong path defined in config for object(path): $type.$name(properties.$path)"
16+
ADFT0011: adf.Location property has not been provided.
17+
18+
19+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ class AdfPublishOption {
77
[Boolean] $DeployGlobalParams = $true
88
[Boolean] $FailsWhenConfigItemNotFound = $true
99
[Boolean] $FailsWhenPathNotFound = $true
10+
[Boolean] $IgnoreLackOfReferencedObject = $false
1011
}

private/Adf.class.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Adf {
1717
[System.Collections.ArrayList] $Factories = @{}
1818
[string] $Location = ""
1919
[AdfGlobalProp] $GlobalFactory = [AdfGlobalProp]::new()
20+
[AdfPublishOption] $PublishOptions
2021

2122
[System.Collections.ArrayList] AllObjects()
2223
{
@@ -49,5 +50,29 @@ class Adf {
4950
return $r
5051
}
5152

53+
[System.Collections.ArrayList] GetUnusedDatasets()
54+
{
55+
[System.Collections.ArrayList] $dataset_list = @{}
56+
$this.DataSets | ForEach-Object { $null = $dataset_list.Add("$($_.Type.ToLower()).$($_.Name)") }
57+
58+
# Collect all objects used by pipelines and dataflows
59+
$list = $this.Pipelines + $this.DataFlows
60+
if ($list.Count -gt 0) {
61+
$list = $list.DependsOn
62+
63+
# Filter list to datasets only
64+
$used = $list | Where-Object { $_.StartsWith('dataset.', "CurrentCultureIgnoreCase") } | `
65+
ForEach-Object { $_.Substring(8).Insert(0, 'dataset.') } | `
66+
Select-Object -Unique
67+
68+
# Remove all used datasets from $dataset_list
69+
$used | ForEach-Object { $dataset_list.Remove($_) }
70+
}
71+
72+
# datasets not removed from the list are the ones not being used
73+
return $dataset_list
74+
}
75+
76+
5277
}
5378

private/AdfObject.class.ps1

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ class AdfObject {
22
[string] $Name
33
[string] $Type
44
[string] $FileName
5-
[System.Collections.Hashtable] $DependsOn = @{}
5+
[System.Collections.ArrayList] $DependsOn = @()
66
[Boolean] $Deployed = $false
77
[Boolean] $ToBeDeployed = $true
88
[Adf] $Adf
99
[PSCustomObject] $Body
1010

11-
[Boolean] AddDependant ([string]$name, [string]$type)
11+
[Boolean] AddDependant ([string]$name, [string]$refType)
1212
{
13-
$type2 = $type.Replace('Reference', '')
14-
if (!$this.DependsOn.ContainsKey($name)) {
15-
$this.DependsOn.Add( $name, $type2 ) | Out-Null
13+
$objType = $refType.Replace('Reference', '')
14+
$fullName = "$objType.$name"
15+
if (!$this.DependsOn.Contains($fullName)) {
16+
$this.DependsOn.Add( $fullName ) | Out-Null
1617
}
1718
return $true
1819
}
@@ -37,23 +38,40 @@ class AdfObject {
3738
return $this.FullName($true)
3839
}
3940

41+
[Boolean] IsNameMatch ([string]$wildcardPattern)
42+
{
43+
$folder = $this.GetFolderName()
44+
$fullname = $this.FullName($false)
45+
$arr = $wildcardPattern.Split('@')
46+
$namePattern = $arr[0]
47+
if ($arr.Count -le 1)
48+
{
49+
$r = ($fullname -like $namePattern)
50+
} else {
51+
$folderPattern = $arr[1]
52+
$r = ($fullname -like $namePattern) -and ( $folder -like $folderPattern )
53+
}
54+
return $r
55+
}
56+
4057
[String] GetFolderName()
4158
{
42-
$ofn = $null
59+
$ofn = ''
4360
if ($this.Body.PSObject.Properties.Name -contains "properties")
4461
{
4562
$o = $this.Body.properties
4663
if ($o.PSobject.Properties.Name -contains "folder")
4764
{
48-
$ofn = $_.Body.properties.folder.name
65+
$ofn = $this.Body.properties.folder.name
4966
}
5067
}
5168
return $ofn
5269
}
5370

71+
static $AllowedTypes = @('integrationRuntime', 'pipeline', 'dataset', 'dataflow', 'linkedService', 'trigger', 'factory')
5472

5573
}
5674

5775
if (!(Get-Variable ADF_FOLDERS -ErrorAction:SilentlyContinue)) {
58-
Set-Variable ADF_FOLDERS -option ReadOnly -value ('integrationRuntime', 'pipeline', 'dataset', 'dataflow', 'linkedService', 'trigger', 'factory')
76+
Set-Variable ADF_FOLDERS -option ReadOnly -value ([AdfObject]::AllowedTypes)
5977
}

private/AdfObjectName.class.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class AdfObjectName {
2+
[string] $Name
3+
[string] $Type
4+
5+
AdfObjectName ([string] $Name, [string] $Type)
6+
{
7+
$this.Name = $Name
8+
$this.Type = $Type
9+
}
10+
11+
AdfObjectName ([string] $FullName)
12+
{
13+
if ($FullName.IndexOf('.') -lt 1) {
14+
Write-Error "Expected format of name for 'FullName' input parameter is: objectType.objectName"
15+
}
16+
$parts = $FullName.Split('.')
17+
if ($parts[0] -notin [AdfObject]::allowedTypes ) {
18+
Write-Error -Message "Unknown object type: $parts[0]."
19+
}
20+
$this.Type = $parts[0]
21+
$this.Name = $parts[1]
22+
}
23+
24+
}
25+

private/ApplyExclusionOptions.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function ApplyExclusionOptions {
22
param(
3-
[Parameter(Mandatory=$True)] [Adf] $adf,
4-
[Parameter(Mandatory=$True)] [AdfPublishOption] $option
3+
[Parameter(Mandatory=$True)] [Adf] $adf
54
)
65

76
Write-Debug "BEGIN: ApplyExclusionOptions()"
87

8+
$option = $adf.PublishOptions
99
if ($option.Excludes.Keys.Count -gt 0 -and $option.Includes.Keys.Count -eq 0)
1010
{
1111
Write-Debug "ENTRY: ApplyExclusionOptions()::Excludes"
@@ -17,8 +17,7 @@ function ApplyExclusionOptions {
1717
$key = $_
1818
$adf.AllObjects() | ForEach-Object {
1919
[AdfObject] $o = $_
20-
$nonDeployable = ($o.FullName($false) -like $key)
21-
#Write-Debug "$($o.FullName($false)) -like $key"
20+
$nonDeployable = $o.IsNameMatch($key)
2221
if ($nonDeployable) { $o.ToBeDeployed = $false }
2322
#Write-Verbose "- $($o.FullName($true)).ToBeDeployed = $($o.ToBeDeployed)"
2423
}
@@ -36,8 +35,7 @@ function ApplyExclusionOptions {
3635
$key = $_
3736
$adf.AllObjects() | ForEach-Object {
3837
[AdfObject] $o = $_
39-
$deployable = ($o.FullName($false) -like $key)
40-
#Write-Debug "$($o.FullName($false)) -like $key"
38+
$deployable = $o.IsNameMatch($key)
4139
if ($deployable) { $o.ToBeDeployed = $true }
4240
#Write-Verbose "- $($o.FullName($true)).ToBeDeployed = $($o.ToBeDeployed)"
4341
}

private/Deploy-AdfObject.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ function Deploy-AdfObject {
2121
{
2222
Write-Debug "Checking all dependencies of [$($obj.Name)]..."
2323
$i = 1
24-
$obj.DependsOn.getEnumerator() | ForEach-Object {
25-
$name = $_.key
26-
$type = $_.value
24+
$obj.DependsOn | ForEach-Object {
25+
$on = [AdfObjectName]::new($_)
26+
$name = $on.Name
27+
$type = $on.Type
2728
Write-Verbose ("$i) Depends on: [$type].[$name]")
2829
$depobj = Get-AdfObjectByName -adf $adf -name "$name" -type "$type"
2930
if ($null -eq $depobj) {
30-
Write-Error "Referenced object [$name] was not found."
31+
if ($adf.PublishOptions.IgnoreLackOfReferencedObject -eq $true) {
32+
Write-Warning "ADFT0006: Referenced object [$type].[$name] was not found. No error raised as user wanted to carry on."
33+
} else {
34+
Write-Error "ADFT0005: Referenced object [$type].[$name] was not found."
35+
}
3136
} else {
3237
Deploy-AdfObject -obj $depobj
3338
}

0 commit comments

Comments
 (0)