Skip to content

Commit 215b25e

Browse files
committed
fix logging issue
1 parent d31f57e commit 215b25e

2 files changed

Lines changed: 38 additions & 38 deletions

File tree

src/ALZ/Public/Remove-AzureDevOpsAccelerator.ps1

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function Remove-AzureDevOpsAccelerator {
155155

156156
# Normalize organization URL
157157
$organizationUrl = Get-NormalizedOrganizationUrl -Organization $AzureDevOpsOrganization
158-
Write-ToConsoleLog "Using Azure DevOps organization: $organizationUrl" -NoNewLine
158+
Write-ToConsoleLog "Using Azure DevOps organization: $organizationUrl"
159159

160160
# Configure Azure DevOps CLI defaults
161161
az devops configure --defaults organization=$organizationUrl 2>&1 | Out-Null
@@ -206,12 +206,12 @@ function Remove-AzureDevOpsAccelerator {
206206
}
207207

208208
$projectList = $allProjects.value
209-
Write-ToConsoleLog "Found $($projectList.Count) total projects in organization: $organizationUrl" -NoNewLine
209+
Write-ToConsoleLog "Found $($projectList.Count) total projects in organization: $organizationUrl"
210210

211211
foreach($project in $projectList) {
212212
foreach($pattern in $ProjectNamePatterns) {
213213
if($project.name -match $pattern) {
214-
Write-ToConsoleLog "Project matches pattern '$pattern': $($project.name)" -NoNewLine
214+
Write-ToConsoleLog "Project matches pattern '$pattern': $($project.name)"
215215
$projectsToDelete += @{
216216
Name = $project.name
217217
Id = $project.id
@@ -221,7 +221,7 @@ function Remove-AzureDevOpsAccelerator {
221221
}
222222
}
223223

224-
Write-ToConsoleLog "Found $($projectsToDelete.Count) projects matching patterns for deletion" -NoNewLine
224+
Write-ToConsoleLog "Found $($projectsToDelete.Count) projects matching patterns for deletion"
225225
}
226226

227227
# Discover agent pools
@@ -234,18 +234,18 @@ function Remove-AzureDevOpsAccelerator {
234234
$allAgentPools = @()
235235
}
236236

237-
Write-ToConsoleLog "Found $($allAgentPools.Count) total agent pools in organization: $organizationUrl" -NoNewLine
237+
Write-ToConsoleLog "Found $($allAgentPools.Count) total agent pools in organization: $organizationUrl"
238238

239239
foreach($pool in $allAgentPools) {
240240
# Skip system pools (Azure Pipelines, Default, etc.)
241241
if($pool.isHosted -or $pool.poolType -eq "automation") {
242-
Write-ToConsoleLog "Skipping hosted/system pool: $($pool.name)" -NoNewLine
242+
Write-ToConsoleLog "Skipping hosted/system pool: $($pool.name)"
243243
continue
244244
}
245245

246246
foreach($pattern in $AgentPoolNamePatterns) {
247247
if($pool.name -match $pattern) {
248-
Write-ToConsoleLog "Agent pool matches pattern '$pattern': $($pool.name)" -NoNewLine
248+
Write-ToConsoleLog "Agent pool matches pattern '$pattern': $($pool.name)"
249249
$agentPoolsToDelete += @{
250250
Name = $pool.name
251251
Id = $pool.id
@@ -255,7 +255,7 @@ function Remove-AzureDevOpsAccelerator {
255255
}
256256
}
257257

258-
Write-ToConsoleLog "Found $($agentPoolsToDelete.Count) agent pools matching patterns for deletion" -NoNewLine
258+
Write-ToConsoleLog "Found $($agentPoolsToDelete.Count) agent pools matching patterns for deletion"
259259
}
260260

261261
# Confirm deletion
@@ -270,12 +270,12 @@ function Remove-AzureDevOpsAccelerator {
270270

271271
if($projectsToDelete.Count -gt 0) {
272272
Write-ToConsoleLog "Projects ($($projectsToDelete.Count)):"
273-
$projectsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" -NoNewLine }
273+
$projectsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" }
274274
}
275275

276276
if($agentPoolsToDelete.Count -gt 0) {
277277
Write-ToConsoleLog "Agent Pools ($($agentPoolsToDelete.Count)):"
278-
$agentPoolsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" -NoNewLine }
278+
$agentPoolsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" }
279279
}
280280

281281
if($PlanMode) {
@@ -307,12 +307,12 @@ function Remove-AzureDevOpsAccelerator {
307307
"Would run: az devops project delete --id $($project.Id) --org $orgUrl --yes" `
308308
-IsPlan -LogFilePath $TempLogFileForPlan
309309
} else {
310-
Write-ToConsoleLog "Deleting project: $($project.Name)" -NoNewLine
310+
Write-ToConsoleLog "Deleting project: $($project.Name)"
311311
$result = az devops project delete --id $project.Id --org $orgUrl --yes 2>&1
312312
if($LASTEXITCODE -ne 0) {
313-
Write-ToConsoleLog "Failed to delete project: $($project.Name)", "Full error: $result" -IsWarning -NoNewLine
313+
Write-ToConsoleLog "Failed to delete project: $($project.Name)", "Full error: $result" -IsWarning
314314
} else {
315-
Write-ToConsoleLog "Deleted project: $($project.Name)" -NoNewLine
315+
Write-ToConsoleLog "Deleted project: $($project.Name)"
316316
}
317317
}
318318
} -ThrottleLimit $ThrottleLimit
@@ -336,12 +336,12 @@ function Remove-AzureDevOpsAccelerator {
336336
"Would run: az pipelines pool delete --id $($pool.Id) --org $orgUrl --yes" `
337337
-IsPlan -LogFilePath $TempLogFileForPlan
338338
} else {
339-
Write-ToConsoleLog "Deleting agent pool: $($pool.Name)" -NoNewLine
339+
Write-ToConsoleLog "Deleting agent pool: $($pool.Name)"
340340
$result = az pipelines pool delete --id $pool.Id --org $orgUrl --yes 2>&1
341341
if($LASTEXITCODE -ne 0) {
342-
Write-ToConsoleLog "Failed to delete agent pool: $($pool.Name)", "Full error: $result" -IsWarning -NoNewLine
342+
Write-ToConsoleLog "Failed to delete agent pool: $($pool.Name)", "Full error: $result" -IsWarning
343343
} else {
344-
Write-ToConsoleLog "Deleted agent pool: $($pool.Name)" -NoNewLine
344+
Write-ToConsoleLog "Deleted agent pool: $($pool.Name)"
345345
}
346346
}
347347
} -ThrottleLimit $ThrottleLimit

src/ALZ/Public/Remove-GitHubAccelerator.ps1

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ function Remove-GitHubAccelerator {
193193
return
194194
}
195195

196-
Write-ToConsoleLog "Found $($allRepositories.Count) total repositories in organization: $GitHubOrganization" -NoNewLine
196+
Write-ToConsoleLog "Found $($allRepositories.Count) total repositories in organization: $GitHubOrganization"
197197

198198
foreach($repo in $allRepositories) {
199199
foreach($pattern in $RepositoryNamePatterns) {
200200
if($repo.name -match $pattern) {
201-
Write-ToConsoleLog "Repository matches pattern '$pattern': $($repo.name)" -NoNewLine
201+
Write-ToConsoleLog "Repository matches pattern '$pattern': $($repo.name)"
202202
$repositoriesToDelete += @{
203203
Name = $repo.name
204204
Url = $repo.url
@@ -208,7 +208,7 @@ function Remove-GitHubAccelerator {
208208
}
209209
}
210210

211-
Write-ToConsoleLog "Found $($repositoriesToDelete.Count) repositories matching patterns for deletion" -NoNewLine
211+
Write-ToConsoleLog "Found $($repositoriesToDelete.Count) repositories matching patterns for deletion"
212212
}
213213

214214
# Discover teams
@@ -221,12 +221,12 @@ function Remove-GitHubAccelerator {
221221
$allTeams = @()
222222
}
223223

224-
Write-ToConsoleLog "Found $($allTeams.Count) total teams in organization: $GitHubOrganization" -NoNewLine
224+
Write-ToConsoleLog "Found $($allTeams.Count) total teams in organization: $GitHubOrganization"
225225

226226
foreach($team in $allTeams) {
227227
foreach($pattern in $TeamNamePatterns) {
228228
if($team.name -match $pattern -or $team.slug -match $pattern) {
229-
Write-ToConsoleLog "Team matches pattern '$pattern': $($team.name) (slug: $($team.slug))" -NoNewLine
229+
Write-ToConsoleLog "Team matches pattern '$pattern': $($team.name) (slug: $($team.slug))"
230230
$teamsToDelete += @{
231231
Name = $team.name
232232
Slug = $team.slug
@@ -237,7 +237,7 @@ function Remove-GitHubAccelerator {
237237
}
238238
}
239239

240-
Write-ToConsoleLog "Found $($teamsToDelete.Count) teams matching patterns for deletion" -NoNewLine
240+
Write-ToConsoleLog "Found $($teamsToDelete.Count) teams matching patterns for deletion"
241241
}
242242

243243
# Discover runner groups
@@ -253,18 +253,18 @@ function Remove-GitHubAccelerator {
253253
}
254254

255255
if($null -ne $allRunnerGroups) {
256-
Write-ToConsoleLog "Found $($allRunnerGroups.Count) total runner groups in organization: $GitHubOrganization" -NoNewLine
256+
Write-ToConsoleLog "Found $($allRunnerGroups.Count) total runner groups in organization: $GitHubOrganization"
257257

258258
foreach($runnerGroup in $allRunnerGroups) {
259259
# Skip the default runner group as it cannot be deleted
260260
if($runnerGroup.name -eq "Default" -or $runnerGroup.default) {
261-
Write-ToConsoleLog "Skipping default runner group: $($runnerGroup.name)" -NoNewLine
261+
Write-ToConsoleLog "Skipping default runner group: $($runnerGroup.name)"
262262
continue
263263
}
264264

265265
foreach($pattern in $RunnerGroupNamePatterns) {
266266
if($runnerGroup.name -match $pattern) {
267-
Write-ToConsoleLog "Runner group matches pattern '$pattern': $($runnerGroup.name)" -NoNewLine
267+
Write-ToConsoleLog "Runner group matches pattern '$pattern': $($runnerGroup.name)"
268268
$runnerGroupsToDelete += @{
269269
Name = $runnerGroup.name
270270
Id = $runnerGroup.id
@@ -274,7 +274,7 @@ function Remove-GitHubAccelerator {
274274
}
275275
}
276276

277-
Write-ToConsoleLog "Found $($runnerGroupsToDelete.Count) runner groups matching patterns for deletion" -NoNewLine
277+
Write-ToConsoleLog "Found $($runnerGroupsToDelete.Count) runner groups matching patterns for deletion"
278278
}
279279
}
280280

@@ -290,17 +290,17 @@ function Remove-GitHubAccelerator {
290290

291291
if($repositoriesToDelete.Count -gt 0) {
292292
Write-ToConsoleLog "Repositories ($($repositoriesToDelete.Count)):"
293-
$repositoriesToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" -NoNewLine }
293+
$repositoriesToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" }
294294
}
295295

296296
if($teamsToDelete.Count -gt 0) {
297297
Write-ToConsoleLog "Teams ($($teamsToDelete.Count)):"
298-
$teamsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name) (slug: $($_.Slug))" -NoNewLine }
298+
$teamsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name) (slug: $($_.Slug))" }
299299
}
300300

301301
if($runnerGroupsToDelete.Count -gt 0) {
302302
Write-ToConsoleLog "Runner Groups ($($runnerGroupsToDelete.Count)):"
303-
$runnerGroupsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" -NoNewLine }
303+
$runnerGroupsToDelete | ForEach-Object { Write-ToConsoleLog " - $($_.Name)" }
304304
}
305305

306306
if($PlanMode) {
@@ -333,12 +333,12 @@ function Remove-GitHubAccelerator {
333333
"Would run: gh repo delete $repoFullName --yes" `
334334
-IsPlan -LogFilePath $TempLogFileForPlan
335335
} else {
336-
Write-ToConsoleLog "Deleting repository: $repoFullName" -NoNewLine
336+
Write-ToConsoleLog "Deleting repository: $repoFullName"
337337
$result = gh repo delete $repoFullName --yes 2>&1
338338
if($LASTEXITCODE -ne 0) {
339-
Write-ToConsoleLog "Failed to delete repository: $repoFullName", "Full error: $result" -IsWarning -NoNewLine
339+
Write-ToConsoleLog "Failed to delete repository: $repoFullName", "Full error: $result" -IsWarning
340340
} else {
341-
Write-ToConsoleLog "Deleted repository: $repoFullName" -NoNewLine
341+
Write-ToConsoleLog "Deleted repository: $repoFullName"
342342
}
343343
}
344344
} -ThrottleLimit $ThrottleLimit
@@ -362,12 +362,12 @@ function Remove-GitHubAccelerator {
362362
"Would run: gh api -X DELETE orgs/$org/teams/$($team.Slug)" `
363363
-IsPlan -LogFilePath $TempLogFileForPlan
364364
} else {
365-
Write-ToConsoleLog "Deleting team: $($team.Name) (slug: $($team.Slug))" -NoNewLine
365+
Write-ToConsoleLog "Deleting team: $($team.Name) (slug: $($team.Slug))"
366366
$result = gh api -X DELETE "orgs/$org/teams/$($team.Slug)" 2>&1
367367
if($LASTEXITCODE -ne 0) {
368-
Write-ToConsoleLog "Failed to delete team: $($team.Name)", "Full error: $result" -IsWarning -NoNewLine
368+
Write-ToConsoleLog "Failed to delete team: $($team.Name)", "Full error: $result" -IsWarning
369369
} else {
370-
Write-ToConsoleLog "Deleted team: $($team.Name)" -NoNewLine
370+
Write-ToConsoleLog "Deleted team: $($team.Name)"
371371
}
372372
}
373373
} -ThrottleLimit $ThrottleLimit
@@ -391,12 +391,12 @@ function Remove-GitHubAccelerator {
391391
"Would run: gh api -X DELETE orgs/$org/actions/runner-groups/$($runnerGroup.Id)" `
392392
-IsPlan -LogFilePath $TempLogFileForPlan
393393
} else {
394-
Write-ToConsoleLog "Deleting runner group: $($runnerGroup.Name)" -NoNewLine
394+
Write-ToConsoleLog "Deleting runner group: $($runnerGroup.Name)"
395395
$result = gh api -X DELETE "orgs/$org/actions/runner-groups/$($runnerGroup.Id)" 2>&1
396396
if($LASTEXITCODE -ne 0) {
397-
Write-ToConsoleLog "Failed to delete runner group: $($runnerGroup.Name)", "Full error: $result" -IsWarning -NoNewLine
397+
Write-ToConsoleLog "Failed to delete runner group: $($runnerGroup.Name)", "Full error: $result" -IsWarning
398398
} else {
399-
Write-ToConsoleLog "Deleted runner group: $($runnerGroup.Name)" -NoNewLine
399+
Write-ToConsoleLog "Deleted runner group: $($runnerGroup.Name)"
400400
}
401401
}
402402
} -ThrottleLimit $ThrottleLimit

0 commit comments

Comments
 (0)