Move the func.yaml schema generator off the archived alecthomas/jsonschema

オープン
#4,190 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, json, yaml
領域
tooling

調査の方向性

Start in schema/generator/main.go, where the reflector is built from github.com/alecthomas/jsonschema, and in pkg/functions/function_options.go, where the jsonschema and jsonschema_extras tags and the scale minimum workaround live. Swap the import to github.com/invopop/jsonschema, regenerate schema/func_yaml-schema.json, and diff it. Done when the schema is regenerated, make check-schema passes, and the draft-04 output decision is recorded.

索引モデルが issue の本文から書いたものです。

説明

schema/generator builds schema/func_yaml-schema.json with github.com/alecthomas/jsonschema, which was archived in 2022 ("Maintenance has moved to https://github.com/invopop/jsonschema"). Its limits now show up as workarounds in our own code:

  • minimum is an int parsed with strconv.Atoi, so a fractional minimum such as scale.kpa.target's 0.01 silently becomes 0. #4067 patches that one field after reflection.
  • A zero minimum is omitted, which is why the scale fields declare minimum through jsonschema_extras (see the comment above the scale tags in pkg/functions/function_options.go).
  • Tag descriptions can't contain commas (another comment in function_options.go).

The maintained successor, github.com/invopop/jsonschema (v0.14.0), keeps the same shape: Reflector, AddGoComments, and the jsonschema / jsonschema_extras tags. It represents minimum/maximum as numbers, so fractional and zero bounds work from the tag directly. The generator is the only Go code that imports the library, so the change is contained.

Possible path:

  1. Swap the import in schema/generator/main.go, regenerate, and diff the schema.
  2. Move minimum back into the jsonschema tag where jsonschema_extras only worked around zero being dropped. Remove the generator patch from #4067.
  3. Decide on the draft version. invopop emits 2020-12 with $defs, where we publish draft-04 with definitions. Either keep draft-04 output, or confirm the YAML language server and editors that consume the schema handle 2020-12 before switching. exclusiveMinimum also changes from a boolean to a number between those drafts.
  4. make check-schema keeps the committed schema in step.

Not urgent: the published schema is only looser than the runtime validation in a few edge cases, and the deploy still rejects invalid values with a clear error.

主要言語
Go
スター
366
フォーク
231
平均マージ
2日 23時間
マージ済み PR(30日)
50

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

knative/func のほかの issue

knative/func の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。