Repository navigation
Expand file tree
/
Copy pathysd-format.t
More file actions
311 lines (288 loc) · 8.45 KB
/
Copy pathysd-format.t
File metadata and controls
311 lines (288 loc) · 8.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#!/usr/bin/env ys-0
use ys::taptest: :all
test::
- name: compact-enums-use-comma-space
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"mode": {
"type": "string",
"enum": ["debug", "info", "warning", "error", "fatal"],
"default": "info"
}
}
}
want: |
# Converted from JSON Schema
.open: true
mode?: +Str [debug, =info, warning, error, fatal]
- name: overlong-enum-and-description-use-separate-clauses
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"mode": {
"type": "string",
"enum": [
"debug mode", "info mode", "warning mode",
"error mode", "fatal mode"
],
"default": "info mode",
"description": "Component logging mode."
}
}
}
want: |
# Converted from JSON Schema
.open: true
mode?: +Str
[debug mode, =info mode, warning mode, error mode, fatal mode]
-"Component logging mode."
- name: long-enum-wraps-only-after-commas
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"mode": {
"type": "string",
"enum": [
"debug", "info", "warning", "error", "fatal",
"extremely-long-alpha-setting",
"extremely-long-beta-setting"
],
"description": "Select the logging behavior used by every component in this deployment."
}
}
}
want: |
# Converted from JSON Schema
.open: true
mode?: +Str
[debug, info, warning, error, fatal, extremely-long-alpha-setting,
extremely-long-beta-setting]
-"Select the logging behavior used by every component in this deployment."
- name: nested-description-wraps-at-physical-column-80
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"harborComponent": {
"type": "object",
"properties": {
"config": {
"type": "object",
"additionalProperties": {},
"description": "Primary component config. For env-driven components (core, exporter, trivy) it is flattened to env vars via toEnvVars. For file-driven components (registry, jobservice) it is the config file body passed through verbatim."
}
}
}
}
}
want: |
# Converted from JSON Schema
.open: true
harborComponent?:
config?: +Map{}
-"Primary component config. For env-driven components (core, exporter,
trivy) it is flattened to env vars via toEnvVars. For file-driven components
(registry, jobservice) it is the config file body passed through verbatim."
- name: long-desc-pair-wraps-at-whitespace
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"storageCredentials": {
"type": "object",
"description": "BYO Secret references for storage credentials. The chart injects REGISTRY_STORAGE_<BACKEND>_<KEY> env vars on both the registry and registryctl containers (distribution honors these env overrides).",
"properties": {
"s3": {"type": "object"}
}
}
}
}
want: |
# Converted from JSON Schema
.open: true
storageCredentials?:
-: BYO Secret references for storage credentials. The chart injects
REGISTRY_STORAGE_<BACKEND>_<KEY> env vars on both the registry and
registryctl containers (distribution honors these env overrides).
s3?: +Map{}
- name: long-list-item-description-wraps
cmnd: bin/ysd -t ysd -
stdi: |
{
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"description": "A structured value with enough descriptive text to wrap cleanly onto a continuation line",
"properties": {"name": {"type": "string"}}
}
]
}
}
}
}
want: |
# Converted from JSON Schema
.open: true
values?:
.one[]:
- +Str
- -: A structured value with enough descriptive text to wrap cleanly onto a
continuation line
name?: +Str
- name: wrapped-desc-pairs-retain-quoted-and-spaced-values
cmnd: |
sh -c '
set -eu
tmp=$(mktemp -d)
trap "rm -r \"$tmp\"" EXIT
cat > "$tmp/in.schema.json"
bin/ysd -t ysd "$tmp/in.schema.json" > "$tmp/out.ysd.yaml"
cat "$tmp/out.ysd.yaml"
bin/ysd -f ysd -t jsc -C "$tmp/out.ysd.yaml" |
ys -e "say: IN:read:json/load.properties.x.description"
'
stdi: |
{
"properties": {
"x": {
"type": "object",
"description": "BYO Secret references: the chart injects many registry storage credential environment variables on both the registry and registryctl containers without changing their values.",
"properties": {"y": {"type": "string"}}
}
}
}
want: |
# Converted from JSON Schema
.open: true
x?:
-: 'BYO Secret references: the chart injects many registry storage credential
environment variables on both the registry and registryctl containers
without changing their values.'
y?: +Str
BYO Secret references: the chart injects many registry storage credential environment variables on both the registry and registryctl containers without changing their values.
- name: desc-pair-wrap-boundary-is-over-80
cmnd: |
sh -c '
for width in 14 15; do
first=$(printf "%060d" 0 | tr 0 a)
last=$(printf "%0${width}d" 0 | tr 0 b)
printf "%s%s\n" \
"{\"properties\":{\"x\":{\"title\":\"X\"," \
"\"description\":\"$first $last\"}}}" |
bin/ysd -t ysd - |
perl -ne \
"chomp; print qq($width ), length, qq(\\n) if /^ -:|^ b/"
done
'
want: |
14 80
15 65
15 19
- name: line-wrap-boundary-is-over-80
cmnd: |
sh -c '
for width in 69 70; do
description=$(printf "%0${width}d" 0 | tr 0 a)
printf \
"{\"properties\":{\"x\":{\"type\":\"string\",\"description\":\"%s\"}}}\n" \
"$description" |
bin/ysd -t ysd - |
perl -ne "chomp; print qq($width ), length, qq(\\n)"
done
'
want: |
69 28
69 11
69 0
69 8
69 74
70 28
70 11
70 0
70 8
70 75
- name: wrapped-description-preserves-escapes-and-spacing
cmnd: |
sh -c '
set -eu
tmp=$(mktemp -d)
trap "rm -r \"$tmp\"" EXIT
cat > "$tmp/in.schema.json"
bin/ysd -t ysd "$tmp/in.schema.json" > "$tmp/out.ysd.yaml"
cat "$tmp/out.ysd.yaml"
bin/ysd -f ysd -t jsc -C "$tmp/out.ysd.yaml" |
ys -e "say: IN:read:json/load.properties.escaped.description"
'
stdi: |
{
"properties": {
"escaped": {
"type": "string",
"description": "this: that # the other foo\\ bar and two spaces plus enough ordinary words to force wrapping safely"
}
}
}
want: |
# Converted from JSON Schema
.open: true
escaped?: +Str
-"this:\ that \# the other foo\ bar and two spaces plus enough ordinary words
to force wrapping safely"
this: that # the other foo\ bar and two spaces plus enough ordinary words to force wrapping safely
- name: indivisible-enum-member-may-exceed-80
cmnd: |
sh -c '
member=$(printf "%090d" 0 | tr 0 a)
printf \
"{\"properties\":{\"x\":{\"type\":\"string\",\"enum\":[\"%s\"]}}}\n" \
"$member" |
bin/ysd -t ysd - |
perl -ne "chomp; print length, qq(\\n)"
'
want: |
28
11
0
8
94
- name: wrapped-enum-and-description-retain-schema-semantics
cmnd: |
sh -c '
set -eu
tmp=$(mktemp -d)
trap "rm -r \"$tmp\"" EXIT
cat > "$tmp/in.schema.json"
bin/ysd -t ysd "$tmp/in.schema.json" > "$tmp/out.ysd.yaml"
bin/ysd -f ysd -t jsc -C "$tmp/out.ysd.yaml" \
> "$tmp/out.schema.json"
ys -pe \
"ARGS.0:read:json/load.properties.mode == ARGS.1:read:json/load.properties.mode" \
-- "$tmp/in.schema.json" "$tmp/out.schema.json"
'
stdi: |
{
"properties": {
"mode": {
"type": "string",
"enum": [
"debug mode", "info mode", "warning mode",
"error mode", "fatal mode"
],
"default": "info mode",
"description": "Component logging mode."
}
}
}
want: |
true
done: