Skip to content

Commit 59a429a

Browse files
authored
Merge pull request #410 from michaeltlombardi/gh-407/main/update-exit-code-schemas
(GH-407) Support negative integers in manifest `exitCodes`
2 parents 0157276 + 916548c commit 59a429a

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

docs/reference/schemas/resource/manifest/root.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,27 @@ information, see the [DSC Resource manifest provider property schema reference][
229229
The `exitCodes` property defines a set of valid exit codes for the resource and their meaning.
230230
Define this property as a set of key-value pairs where:
231231

232-
- The key is a string containing an integer that maps to a known exit code for the resource.
232+
- The key is a string containing a signed integer that maps to a known exit code for the resource.
233+
The exit code must be a literal signed integer. You can't use alternate formats for the exit
234+
code. For example, instead of the hexadecimal value `0x80070005` for "Access denied", specify the
235+
exit code as `-2147024891`.
233236
- The value is a string describing the semantic meaning of that exit code for a human reader.
234237

235238
DSC interprets exit code `0` as a successful operation and any other exit code as an error.
236239

240+
> [!TIP]
241+
> If you're authoring your resource manifest in yaml, be sure to wrap the exit code in single
242+
> quotes to ensure the YAML file can be parsed correctly. For example:
243+
>
244+
> ```yaml
245+
> exitCodes:
246+
> '0': Success
247+
> '1': Invalid parameter
248+
> '2': Invalid input
249+
> '3': Registry error
250+
> '4': JSON serialization failed
251+
> ```
252+
237253
```yaml
238254
Type: object
239255
Required: false

schemas/2024/04/bundled/outputs/resource/list.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@
219219
"description": "This property defines a map of valid exit codes for the DSC Resource. DSC always interprets exit code `0` as a successful operation and any other exit code as an error. Use this property to indicate human-readable semantic meanings for the DSC Resource's exit codes.",
220220
"type": "object",
221221
"propertyNames": {
222-
"pattern": "^[0-9]+$"
222+
"pattern": "^-?[0-9]+$"
223223
},
224224
"patternProperties": {
225-
"^[0-9]+$": {
225+
"^-?[0-9]+$": {
226226
"type": "string"
227227
}
228228
},

schemas/2024/04/bundled/outputs/resource/list.vscode.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@
535535
"description": "This property defines a map of valid exit codes for the DSC Resource. DSC always interprets exit code `0` as a successful operation and any other exit code as an error. Use this property to indicate human-readable semantic meanings for the DSC Resource's exit codes.",
536536
"type": "object",
537537
"propertyNames": {
538-
"pattern": "^[0-9]+$",
539-
"patternErrorMessage": "Invalid exit code. Must be a string representing an integer greater than or equal to `0`.\n"
538+
"pattern": "^-?[0-9]+$",
539+
"patternErrorMessage": "Invalid exit code. Must be a string representing a 32-bit signed integer.\n"
540540
},
541541
"patternProperties": {
542-
"^[0-9]+$": {
542+
"^-?[0-9]+$": {
543543
"type": "string"
544544
}
545545
},
@@ -557,7 +557,7 @@
557557
"4": "JSON serialization failed"
558558
}
559559
],
560-
"markdownDescription": "***\n[_Online Documentation_][01]\n***\n\nThis property defines a map of valid exit codes for the DSC Resource. DSC always interprets\nexit code `0` as a successful operation and any other exit code as an error. Use this\nproperty to indicate human-readable semantic meanings for the DSC Resource's exit codes.\n\n[01]: https://learn.microsoft.com/powershell/dsc/reference/schemas/resource/manifest/root?view=dsc-3.0&preserve-view=true#exitcodes\n",
560+
"markdownDescription": "***\n[_Online Documentation_][01]\n***\n\nThis property defines a map of valid exit codes for the DSC Resource. DSC always interprets\nexit code `0` as a successful operation and any other exit code as an error. Use this\nproperty to indicate human-readable semantic meanings for the DSC Resource's exit codes.\n\nDefine the keys in this property as strings representing a valid 32-bit signed integer. You\ncan't use alternate formats for the exit code. For example, instead of the hexadecimal value\n`0x80070005` for \"Access denied\", specify the exit code as `-2147024891`. If you're authoring\nyour resource manifest in yaml, be sure to wrap the exit code in single quotes, like\n`'0': Success` instead of `0: Success` to ensure the YAML file can be parsed correctly.\n\nDefine the value for each key as a string explaining what the exit code indicates.\n\n[01]: https://learn.microsoft.com/powershell/dsc/reference/schemas/resource/manifest/root?view=dsc-3.0&preserve-view=true#exitcodes\n",
561561
"defaultSnippets": [
562562
{
563563
"label": " Defined exit codes",

schemas/2024/04/bundled/resource/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
"description": "This property defines a map of valid exit codes for the DSC Resource. DSC always interprets exit code `0` as a successful operation and any other exit code as an error. Use this property to indicate human-readable semantic meanings for the DSC Resource's exit codes.",
8181
"type": "object",
8282
"propertyNames": {
83-
"pattern": "^[0-9]+$"
83+
"pattern": "^-?[0-9]+$"
8484
},
8585
"patternProperties": {
86-
"^[0-9]+$": {
86+
"^-?[0-9]+$": {
8787
"type": "string"
8888
}
8989
},

schemas/2024/04/bundled/resource/manifest.vscode.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@
287287
"description": "This property defines a map of valid exit codes for the DSC Resource. DSC always interprets exit code `0` as a successful operation and any other exit code as an error. Use this property to indicate human-readable semantic meanings for the DSC Resource's exit codes.",
288288
"type": "object",
289289
"propertyNames": {
290-
"pattern": "^[0-9]+$",
291-
"patternErrorMessage": "Invalid exit code. Must be a string representing an integer greater than or equal to `0`.\n"
290+
"pattern": "^-?[0-9]+$",
291+
"patternErrorMessage": "Invalid exit code. Must be a string representing a 32-bit signed integer.\n"
292292
},
293293
"patternProperties": {
294-
"^[0-9]+$": {
294+
"^-?[0-9]+$": {
295295
"type": "string"
296296
}
297297
},
@@ -309,7 +309,7 @@
309309
"4": "JSON serialization failed"
310310
}
311311
],
312-
"markdownDescription": "***\n[_Online Documentation_][01]\n***\n\nThis property defines a map of valid exit codes for the DSC Resource. DSC always interprets\nexit code `0` as a successful operation and any other exit code as an error. Use this\nproperty to indicate human-readable semantic meanings for the DSC Resource's exit codes.\n\n[01]: https://learn.microsoft.com/powershell/dsc/reference/schemas/resource/manifest/root?view=dsc-3.0&preserve-view=true#exitcodes\n",
312+
"markdownDescription": "***\n[_Online Documentation_][01]\n***\n\nThis property defines a map of valid exit codes for the DSC Resource. DSC always interprets\nexit code `0` as a successful operation and any other exit code as an error. Use this\nproperty to indicate human-readable semantic meanings for the DSC Resource's exit codes.\n\nDefine the keys in this property as strings representing a valid 32-bit signed integer. You\ncan't use alternate formats for the exit code. For example, instead of the hexadecimal value\n`0x80070005` for \"Access denied\", specify the exit code as `-2147024891`. If you're authoring\nyour resource manifest in yaml, be sure to wrap the exit code in single quotes, like\n`'0': Success` instead of `0: Success` to ensure the YAML file can be parsed correctly.\n\nDefine the value for each key as a string explaining what the exit code indicates.\n\n[01]: https://learn.microsoft.com/powershell/dsc/reference/schemas/resource/manifest/root?view=dsc-3.0&preserve-view=true#exitcodes\n",
313313
"defaultSnippets": [
314314
{
315315
"label": " Defined exit codes",

schemas/2024/04/resource/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
"description": "This property defines a map of valid exit codes for the DSC Resource. DSC always interprets exit code `0` as a successful operation and any other exit code as an error. Use this property to indicate human-readable semantic meanings for the DSC Resource's exit codes.",
8181
"type": "object",
8282
"propertyNames": {
83-
"pattern": "^[0-9]+$"
83+
"pattern": "^-?[0-9]+$"
8484
},
8585
"patternProperties": {
86-
"^[0-9]+$": {
86+
"^-?[0-9]+$": {
8787
"type": "string"
8888
}
8989
},

schemas/src/resource/manifest.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ properties:
444444
property to indicate human-readable semantic meanings for the DSC Resource's exit codes.
445445
type: object
446446
propertyNames:
447-
pattern: "^[0-9]+$"
447+
pattern: "^-?[0-9]+$"
448448
patternErrorMessage: |
449-
Invalid exit code. Must be a string representing an integer greater than or equal to `0`.
449+
Invalid exit code. Must be a string representing a 32-bit signed integer.
450450
patternProperties:
451-
"^[0-9]+$":
451+
"^-?[0-9]+$":
452452
type: string
453453
unevaluatedProperties: false
454454
default:
@@ -470,6 +470,14 @@ properties:
470470
exit code `0` as a successful operation and any other exit code as an error. Use this
471471
property to indicate human-readable semantic meanings for the DSC Resource's exit codes.
472472
473+
Define the keys in this property as strings representing a valid 32-bit signed integer. You
474+
can't use alternate formats for the exit code. For example, instead of the hexadecimal value
475+
`0x80070005` for "Access denied", specify the exit code as `-2147024891`. If you're authoring
476+
your resource manifest in yaml, be sure to wrap the exit code in single quotes, like
477+
`'0': Success` instead of `0: Success` to ensure the YAML file can be parsed correctly.
478+
479+
Define the value for each key as a string explaining what the exit code indicates.
480+
473481
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/root?<DOCS_VERSION_PIN>#exitcodes
474482
defaultSnippets:
475483
- label: ' Defined exit codes'

0 commit comments

Comments
 (0)