@@ -240,7 +240,7 @@ function _M.run()
240
240
end
241
241
242
242
243
- local schema_patch
243
+ local patch_schema
244
244
do
245
245
local resource_schema = {
246
246
" proto" ,
254
254
" ssl" ,
255
255
" plugin_config" ,
256
256
}
257
- function schema_patch ()
257
+ local function attach_modifiedIndex_schema (name )
258
+ local schema = core .schema [name ]
259
+ if not schema then
260
+ core .log .error (" schema for " , name , " not found" )
261
+ return
262
+ end
263
+ if schema .properties and not schema .properties .modifiedIndex then
264
+ schema .properties .modifiedIndex = {
265
+ type = " integer" ,
266
+ }
267
+ end
268
+ end
269
+
270
+ local function patch_credential_schema ()
271
+ local credential_schema = core .schema [" credential" ]
272
+ if credential_schema and credential_schema .properties then
273
+ credential_schema .properties .id = {
274
+ type = " string" ,
275
+ minLength = 15 ,
276
+ maxLength = 128 ,
277
+ pattern = [[ ^[a-zA-Z0-9]+/credentials/[a-zA-Z0-9]+$]] ,
278
+ }
279
+ end
280
+ end
281
+
282
+ function patch_schema ()
283
+ -- attach modifiedIndex schema to all resource schemas
258
284
for _ , name in ipairs (resource_schema ) do
259
- local schema = core .schema [name ]
260
- if not schema then
261
- core .log .error (" schema for " , name , " not found" )
262
- end
263
- if schema and schema .properties then
264
- schema .properties .modifiedIndex = {
265
- type = " integer" ,
266
- }
267
- end
285
+ attach_modifiedIndex_schema (name )
268
286
end
287
+ -- patch credential schema
288
+ patch_credential_schema ()
269
289
end
270
290
end
271
291
@@ -287,7 +307,7 @@ function _M.init_worker()
287
307
end
288
308
events :register (update_config , EVENT_UPDATE , EVENT_UPDATE )
289
309
290
- schema_patch ()
310
+ patch_schema ()
291
311
end
292
312
293
313
0 commit comments