Skip to content

Commit 81d6913

Browse files
committed
Add 'source' and 'isSynced' properties to template entities
Introduces 'source' and 'isSynced' properties to template objects across multiple modules for improved traceability and synchronization status. Updates Import-CommunityTemplate and related functions to handle and propagate the new properties.
1 parent 2c4f860 commit 81d6913

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ListIntuneTemplates.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ function Invoke-ListIntuneTemplates {
3939
$data | Add-Member -NotePropertyName 'Type' -NotePropertyValue $JSONData.Type -Force
4040
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force
4141
$data | Add-Member -NotePropertyName 'package' -NotePropertyValue $_.Package -Force
42-
$data | Add-Member -NotePropertyName 'isSynced' -NotePropertyValue (![string]::IsNullOrEmpty($_.SHA))
42+
$data | Add-Member -NotePropertyName 'isSynced' -NotePropertyValue (![string]::IsNullOrEmpty($_.SHA)) -Force
43+
$data | Add-Member -NotePropertyName 'source' -NotePropertyValue $_.Source -Force
4344
$data
4445
} catch {
4546

@@ -65,6 +66,8 @@ function Invoke-ListIntuneTemplates {
6566
$data | Add-Member -NotePropertyName 'Type' -NotePropertyValue $JSONData.Type -Force
6667
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force
6768
$data | Add-Member -NotePropertyName 'package' -NotePropertyValue $_.Package -Force
69+
$data | Add-Member -NotePropertyName 'source' -NotePropertyValue $_.Source -Force
70+
$data | Add-Member -NotePropertyName 'isSynced' -NotePropertyValue (![string]::IsNullOrEmpty($_.SHA)) -Force
6871
$data
6972
} catch {
7073

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups/Invoke-ListGroupTemplates.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function Invoke-ListGroupTemplates {
4848
allowExternal = $data.allowExternal
4949
username = $data.username
5050
GUID = $_.RowKey
51+
source = $_.Source
52+
isSynced = (![string]::IsNullOrEmpty($_.SHA))
5153
}
5254
} catch {
5355
Write-Information "Could not parse group template $($_.RowKey): $($_.Exception.Message)"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Conditional/Invoke-ListCAtemplates.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function Invoke-ListCAtemplates {
3535
$row = $_
3636
$data = $row.JSON | ConvertFrom-Json -Depth 100 -ErrorAction Stop
3737
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $row.GUID -Force
38+
$data | Add-Member -NotePropertyName 'source' -NotePropertyValue $row.Source -Force
39+
$data | Add-Member -NotePropertyName 'isSynced' -NotePropertyValue (![string]::IsNullOrEmpty($row.SHA)) -Force
3840
$data
3941
} catch {
4042
Write-Warning "Failed to process CA template: $($row.RowKey) - $($_.Exception.Message)"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-listStandardTemplates.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function Invoke-listStandardTemplates {
2323
}
2424
if ($Data) {
2525
$Data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.GUID -Force
26+
$Data | Add-Member -NotePropertyName 'source' -NotePropertyValue $_.Source -Force
27+
$Data | Add-Member -NotePropertyName 'isSynced' -NotePropertyValue (![string]::IsNullOrEmpty($_.SHA)) -Force
2628

2729
if (!$Data.excludedTenants) {
2830
$Data | Add-Member -NotePropertyName 'excludedTenants' -NotePropertyValue @() -Force

Modules/CIPPCore/Public/New-CIPPTemplateRun.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function New-CIPPTemplateRun {
6464

6565
if (!$ExistingTemplate -or $UpdateNeeded) {
6666
$Template = (Get-GitHubFileContents -FullName $TemplateSettings.templateRepo.value -Branch $TemplateSettings.templateRepoBranch.value -Path $File.path).content | ConvertFrom-Json
67-
Import-CommunityTemplate -Template $Template -SHA $File.sha -MigrationTable $MigrationTable -LocationData $LocationData
67+
Import-CommunityTemplate -Template $Template -SHA $File.sha -MigrationTable $MigrationTable -LocationData $LocationData -Source $TemplateSettings.templateRepo.value
6868
if ($UpdateNeeded) {
6969
Write-Information "Template $($File.name) needs to be updated as the SHA is different"
7070
"Template $($File.name) updated"

Modules/CIPPCore/Public/Tools/Import-CommunityTemplate.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function Import-CommunityTemplate {
99
$SHA,
1010
$MigrationTable,
1111
$LocationData,
12+
$Source,
1213
[switch]$Force
1314
)
1415

@@ -64,6 +65,7 @@ function Import-CommunityTemplate {
6465
$NewJSON = [string]($NewJSON | ConvertTo-Json -Depth 100 -Compress)
6566
$Template.JSON = $NewJSON
6667
$Template | Add-Member -MemberType NoteProperty -Name SHA -Value $SHA -Force
68+
$Template | Add-Member -MemberType NoteProperty -Name Source -Value $Source -Force
6769
Add-CIPPAzDataTableEntity @Table -Entity $Template -Force
6870
} else {
6971
if ($Template.mailNickname) { $Type = 'Group' }
@@ -86,6 +88,7 @@ function Import-CommunityTemplate {
8688
SHA = $SHA
8789
GUID = $Template.id
8890
RowKey = $Template.id
91+
Source = $Source
8992
}
9093
Add-CIPPAzDataTableEntity @Table -Entity $entity -Force
9194
break
@@ -121,13 +124,13 @@ function Import-CommunityTemplate {
121124
}
122125
}
123126

124-
125127
$entity = @{
126128
JSON = "$RawJson"
127129
PartitionKey = 'CATemplate'
128130
SHA = $SHA
129131
GUID = $ID
130132
RowKey = $ID
133+
Source = $Source
131134
}
132135
Add-CIPPAzDataTableEntity @Table -Entity $entity -Force
133136
break
@@ -162,6 +165,7 @@ function Import-CommunityTemplate {
162165
SHA = $SHA
163166
GUID = $ID
164167
RowKey = $ID
168+
Source = $Source
165169
}
166170

167171
if ($Existing -and $Existing.Package) {

0 commit comments

Comments
 (0)