You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contains utility functions used by the WorkflowPostProcess action and its tests
7
+
#>
8
+
9
+
<#
10
+
.SYNOPSIS
11
+
Calculate the duration of a workflow from a start time
12
+
13
+
.DESCRIPTION
14
+
Calculates the duration in seconds from the provided start time to the current UTC time.
15
+
Handles both DateTime objects and string representations in any date format that can be parsed by the invariant culture (e.g., ISO 8601 or other culture-independent formats).
16
+
17
+
.PARAMETERStartTime
18
+
The workflow start time as either a DateTime object or a string in any date format that can be parsed by the invariant culture (such as ISO 8601 or other culture-independent formats)
19
+
20
+
.PARAMETEREndTime
21
+
(Optional) The end time as a DateTime object. Defaults to the current UTC time.
# Validate that the value type matches the input type
357
-
$validationError=$null
358
-
if ($inputType) {
359
-
switch ($inputType) {
360
-
'boolean' {
361
-
if ($defaultValue-isnot [bool]) {
362
-
$validationError="Workflow '$workflowName', input '$inputName': Expected boolean value, but got $($defaultValue.GetType().Name). Please use `$true or `$false."
363
-
}
394
+
# Validate that the value type matches the input type
395
+
$validationError=$null
396
+
if ($inputType) {
397
+
switch ($inputType) {
398
+
'boolean' {
399
+
if ($defaultValue-isnot [bool]) {
400
+
$validationError="Workflow '$workflowName', input '$inputName': Expected boolean value, but got $($defaultValue.GetType().Name). Please use `$true or `$false."
364
401
}
365
-
'number' {
366
-
if ($defaultValue-isnot [int] -and$defaultValue-isnot [long] -and$defaultValue-isnot [double]) {
367
-
$validationError="Workflow '$workflowName', input '$inputName': Expected number value, but got $($defaultValue.GetType().Name)."
368
-
}
402
+
}
403
+
'number' {
404
+
if ($defaultValue-isnot [int] -and$defaultValue-isnot [long] -and$defaultValue-isnot [double]) {
405
+
$validationError="Workflow '$workflowName', input '$inputName': Expected number value, but got $($defaultValue.GetType().Name)."
369
406
}
370
-
'string' {
371
-
if ($defaultValue-isnot [string]) {
372
-
$validationError="Workflow '$workflowName', input '$inputName': Expected string value, but got $($defaultValue.GetType().Name)."
373
-
}
407
+
}
408
+
'string' {
409
+
if ($defaultValue-isnot [string]) {
410
+
$validationError="Workflow '$workflowName', input '$inputName': Expected string value, but got $($defaultValue.GetType().Name)."
374
411
}
375
-
'choice' {
376
-
# Choice inputs accept strings and must match one of the available options (case-sensitive)
377
-
if ($defaultValue-isnot [string]) {
378
-
$validationError="Workflow '$workflowName', input '$inputName': Expected string value for choice input, but got $($defaultValue.GetType().Name)."
379
-
}
380
-
else {
381
-
# Validate that the value is one of the available options
382
-
$optionsStart=0
383
-
$optionsCount=0
384
-
if ($inputSection.Find('options:', [ref] $optionsStart, [ref] $optionsCount)) {
385
-
$availableOptions=@()
386
-
# Parse the options from the YAML (they are indented list items starting with "- ")
387
-
for ($i=$optionsStart+1; $i-lt ($optionsStart+$optionsCount); $i++) {
388
-
$optionLine=$inputSection.content[$i].Trim()
389
-
if ($optionLine-match'^-\s*(.+)$') {
390
-
$availableOptions+=$matches[1].Trim()
391
-
}
412
+
}
413
+
'choice' {
414
+
# Choice inputs accept strings and must match one of the available options (case-sensitive)
415
+
if ($defaultValue-isnot [string]) {
416
+
$validationError="Workflow '$workflowName', input '$inputName': Expected string value for choice input, but got $($defaultValue.GetType().Name)."
417
+
}
418
+
else {
419
+
# Validate that the value is one of the available options
420
+
$optionsStart=0
421
+
$optionsCount=0
422
+
if ($inputSection.Find('options:', [ref] $optionsStart, [ref] $optionsCount)) {
423
+
$availableOptions=@()
424
+
# Parse the options from the YAML (they are indented list items starting with "- ")
425
+
for ($i=$optionsStart+1; $i-lt ($optionsStart+$optionsCount); $i++) {
426
+
$optionLine=$inputSection.content[$i].Trim()
427
+
if ($optionLine-match'^-\s*(.+)$') {
428
+
$availableOptions+=$matches[1].Trim()
392
429
}
430
+
}
393
431
394
-
if ($availableOptions.Count-gt0-and$availableOptions-cnotcontains$defaultValue) {
395
-
$validationError="Workflow '$workflowName', input '$inputName': Value '$defaultValue' is not a valid choice (case-sensitive match required). Available options: $($availableOptions-join', ')."
396
-
}
432
+
if ($availableOptions.Count-gt0-and$availableOptions-cnotcontains$defaultValue) {
433
+
$validationError="Workflow '$workflowName', input '$inputName': Value '$defaultValue' is not a valid choice (case-sensitive match required). Available options: $($availableOptions-join', ')."
397
434
}
398
435
}
399
436
}
400
437
}
401
438
}
402
-
else {
403
-
# If no type is specified in the workflow, it defaults to string
404
-
if ($defaultValue-isnot [string]) {
405
-
OutputWarning "Workflow '$workflowName', input '$inputName': No type specified in workflow (defaults to string), but configured value is $($defaultValue.GetType().Name). This may cause issues."
406
-
}
439
+
}
440
+
else {
441
+
# If no type is specified in the workflow, it defaults to string
442
+
if ($defaultValue-isnot [string]) {
443
+
OutputWarning "Workflow '$workflowName', input '$inputName': No type specified in workflow (defaults to string), but configured value is $($defaultValue.GetType().Name). This may cause issues."
407
444
}
445
+
}
408
446
409
-
if ($validationError) {
410
-
throw$validationError
411
-
}
447
+
if ($validationError) {
448
+
throw$validationError
449
+
}
412
450
413
-
# Convert the default value to the appropriate YAML format
414
-
$yamlValue=$defaultValue
415
-
if ($defaultValue-is [bool]) {
416
-
$yamlValue=$defaultValue.ToString().ToLower()
417
-
}
418
-
elseif ($defaultValue-is [string]) {
419
-
# Quote strings and escape single quotes per YAML spec
420
-
$escapedValue=$defaultValue.Replace("'","''")
421
-
$yamlValue="'$escapedValue'"
422
-
}
451
+
# Convert the default value to the appropriate YAML format
452
+
$yamlValue=$defaultValue
453
+
if ($defaultValue-is [bool]) {
454
+
$yamlValue=$defaultValue.ToString().ToLower()
455
+
}
456
+
elseif ($defaultValue-is [string]) {
457
+
# Quote strings and escape single quotes per YAML spec
458
+
$escapedValue=$defaultValue.Replace("'","''")
459
+
$yamlValue="'$escapedValue'"
460
+
}
423
461
424
-
# Find and replace the default: line in the input section
425
-
$start=0
426
-
$count=0
427
-
if ($inputSection.Find('default:', [ref] $start, [ref] $count)) {
# Analyze InstallApps and InstallTestApps before launching pipeline
239
244
245
+
240
246
# Check if codeSignCertificateUrl+Password is used (and defined)
241
247
if (!$settings.doNotSignApps-and$codeSignCertificateUrl-and$codeSignCertificatePassword-and!$settings.keyVaultCodesignCertificateName) {
242
248
OutputWarning -message "Using the legacy CodeSignCertificateUrl and CodeSignCertificatePassword parameters. Consider using the new Azure Keyvault signing instead. Go to https://aka.ms/ALGoSettings#keyVaultCodesignCertificateName to find out more"
0 commit comments