Skip to content

Commit 48081f8

Browse files
Schema updates
1 parent 5aab0e8 commit 48081f8

File tree

3 files changed

+79
-26
lines changed

3 files changed

+79
-26
lines changed

src/dsc/psresourceget.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function SetPSResources {
172172
$versionRange = [NuGet.Versioning.VersionRange]::Parse($version)
173173
$resourceVersion = [NuGet.Versioning.NuGetVersion]::Parse($_.Version.ToString())
174174
if (-not $versionRange.Satisfies($resourceVersion)) {
175-
if ($resource._exists) {
175+
if ($resource._exist) {
176176
#$resourcesToInstall += $resource
177177
$key = $resource.Name.ToLowerInvariant() + '-' + $resource.Version.ToLowerInvariant()
178178
if (-not $resourcesToInstall.ContainsKey($key)) {
@@ -183,7 +183,7 @@ function SetPSResources {
183183
$resourcesToUninstall += $_
184184
}
185185
else {
186-
if (-not $resource._exists) {
186+
if (-not $resource._exist) {
187187
$resourcesToUninstall += $_
188188
}
189189
}
@@ -285,7 +285,7 @@ function PopulatePSResourcesObjectByRepository {
285285
[pscustomobject]@{
286286
name = $_.Name
287287
version = $_.Version.ToString()
288-
_exists = $false
288+
_exist = $false
289289
}
290290
}
291291
}
@@ -294,7 +294,7 @@ function PopulatePSResourcesObjectByRepository {
294294
[pscustomobject]@{
295295
name = $_.Name
296296
version = $_.Version.ToString()
297-
_exists = $true
297+
_exist = $true
298298
}
299299
}
300300

@@ -331,7 +331,7 @@ function PopulatePSResourcesObject {
331331
[pscustomobject]@{
332332
name = $_.Name
333333
version = $_.Version.ToString()
334-
_exists = $true
334+
_exist = $true
335335
}
336336
}
337337

@@ -350,7 +350,7 @@ function PopulateRepositoryObject {
350350
)
351351

352352
$repository = if (-not $RepositoryInfo) {
353-
Write-Trace -message "RepositoryInfo is null or empty. Returning _exists = false" -Level Information
353+
Write-Trace -message "RepositoryInfo is null or empty. Returning _exist = false" -Level Information
354354

355355
$inputJson = $stdinput | ConvertFrom-Json -ErrorAction Stop
356356

@@ -360,7 +360,7 @@ function PopulateRepositoryObject {
360360
trusted = $inputJson.Trusted
361361
priority = $inputJson.Priority
362362
repositoryType = $inputJson.repositoryType
363-
_exists = $false
363+
_exist = $false
364364
}
365365
}
366366
else {
@@ -371,7 +371,7 @@ function PopulateRepositoryObject {
371371
trusted = $RepositoryInfo.Trusted
372372
priority = $RepositoryInfo.Priority
373373
repositoryType = $RepositoryInfo.ApiVersion
374-
_exists = $true
374+
_exist = $true
375375
}
376376
}
377377

src/dsc/psresources.dsc.resource.json

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
33
"description": "Manage PowerShell resources using PSResourceGet.",
4-
"type": "Microsoft.PowerShell.PSResourceGet/PSResources",
4+
"type": "Microsoft.PowerShell.PSResourceGet/PSResourceList",
55
"version": "0.0.1",
66
"get": {
77
"executable": "pwsh",
@@ -10,7 +10,7 @@
1010
"-NonInteractive",
1111
"-NoProfile",
1212
"-Command",
13-
"$Input | ./psresourceget.ps1 -resourcetype 'psresources' -operation 'get'"
13+
"$Input | ./psresourceget.ps1 -resourcetype 'psresourcelist' -operation 'get'"
1414
],
1515
"input": "stdin"
1616
},
@@ -21,9 +21,10 @@
2121
"-NonInteractive",
2222
"-NoProfile",
2323
"-Command",
24-
"$Input | ./psresourceget.ps1 -resourcetype 'psresources' -operation set"
24+
"$Input | ./psresourceget.ps1 -resourcetype 'psresourcelist' -operation set"
2525
],
26-
"input": "stdin"
26+
"input": "stdin",
27+
"return": "stateAndDiff"
2728
},
2829
"export": {
2930
"executable": "pwsh",
@@ -32,14 +33,26 @@
3233
"-NonInteractive",
3334
"-NoProfile",
3435
"-Command",
35-
"./psresourceget.ps1 -resourcetype 'psresources' -operation export"
36+
"./psresourceget.ps1 -resourcetype 'psresourcelist' -operation export"
3637
],
3738
"input": "stdin"
3839
},
40+
"test": {
41+
"executable": "pwsh",
42+
"args": [
43+
"-NoLogo",
44+
"-NonInteractive",
45+
"-NoProfile",
46+
"-Command",
47+
"$Input | ./psresourceget.ps1 -resourcetype 'psresourcelist' -operation test"
48+
],
49+
"input": "stdin",
50+
"return": "stateAndDiff"
51+
},
3952
"schema": {
4053
"embedded": {
4154
"$schema": "http://json-schema.org/draft-2020-12/schema#",
42-
"title": "PSResources",
55+
"title": "PSResourceList",
4356
"type": "object",
4457
"additionalProperties": false,
4558
"properties": {
@@ -50,8 +63,9 @@
5063
},
5164
"scope": {
5265
"title": "Scope",
53-
"description": "The scope of the resources. Can be 'CurrentUser' or 'AllUsers'.",
66+
"description": "The scope of the resources. Can be 'CurrentUser' or 'AllUsers'. Defaults to 'CurrentUser'.",
5467
"$ref": "#/$defs/Scope",
68+
"default": "CurrentUser",
5569
"writeOnly": true
5670
},
5771
"resources": {
@@ -65,7 +79,7 @@
6579
},
6680
"$defs": {
6781
"Scope": {
68-
"type": "integer",
82+
"type": "string",
6983
"title": "Scope",
7084
"description": "Scope of the resource installation.",
7185
"enum": [
@@ -76,6 +90,9 @@
7690
"PSResource": {
7791
"type": "object",
7892
"additionalProperties": false,
93+
"required": [
94+
"name"
95+
],
7996
"properties": {
8097
"name": {
8198
"title": "Name",
@@ -86,12 +103,13 @@
86103
"title": "Version",
87104
"description": "The version range of the resource.",
88105
"type": "string"
106+
// Look at nuget versioning for format
107+
// returning back semantic version by adding prerelease
89108
},
90109
"scope": {
91110
"title": "Scope",
92111
"description": "The scope of the resource. Can be 'CurrentUser' or 'AllUsers'.",
93-
"$ref": "#/$defs/Scope",
94-
"writeOnly": true
112+
"$ref": "#/$defs/Scope"
95113
},
96114
"repositoryName": {
97115
"title": "Repository Name",
@@ -102,11 +120,21 @@
102120
"title": "Pre-Release version",
103121
"description": "Indicates whether to include pre-release versions of the resource.",
104122
"type": "boolean",
105-
"writeOnly": true
123+
"default": false
124+
},
125+
"_exist": {
126+
"$ref": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/exist.json"
106127
},
107-
"_exists": {
108-
"type": "boolean"
128+
"_inDesiredState": {
129+
"$ref": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/inDesiredState.json"
109130
}
131+
132+
// for test and set everything
133+
// 2 json lines
134+
// state == current state of object
135+
// diff == array of properties that are different
136+
137+
// for other operations, DONOT return _inDesiredState
110138
}
111139
}
112140
}

src/dsc/repository.dsc.resource.json

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@
4343
"description": "A PowerShell Resource repository from where to acquire the resources.",
4444
"type": "object",
4545
"additionalProperties": false,
46+
"allOf": [
47+
{
48+
"if": {
49+
"properties": {
50+
"_exist": {
51+
"const": false
52+
}
53+
}
54+
},
55+
"then": {
56+
"required": [
57+
"name"
58+
]
59+
},
60+
"else": {
61+
"required": [
62+
"name",
63+
"uri"
64+
]
65+
}
66+
}
67+
],
4668
"properties": {
4769
"name": {
4870
"title": "Name",
@@ -52,7 +74,8 @@
5274
"uri": {
5375
"title": "URI",
5476
"description": "The URI of the repository.",
55-
"type": "string"
77+
"type": "string",
78+
"format": "uri"
5679
},
5780
"trusted": {
5881
"title": "Trusted",
@@ -62,20 +85,22 @@
6285
"priority": {
6386
"title": "Priority",
6487
"description": "The priority of the repository. Lower numbers indicate higher priority.",
65-
"type": "integer"
88+
"type": "integer",
89+
"minimum": 0,
90+
"maximum": 100
6691
},
6792
"repositoryType": {
6893
"title": "Repository Type",
6994
"description": "The type of the repository.",
7095
"$ref": "#/$defs/RepositoryType"
7196
},
72-
"_exists": {
73-
"type": "boolean"
97+
"_exist": {
98+
"$ref": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/exist.json"
7499
}
75100
},
76101
"$defs": {
77102
"RepositoryType": {
78-
"type": "integer",
103+
"type": "string",
79104
"title": "Repository Type",
80105
"description": "The type of the repository. Can be 'Unknown', 'V2', 'V3', 'Local', 'NugetServer', or 'ContainerRegistry'.",
81106
"enum": [

0 commit comments

Comments
 (0)