-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add targeting schema, improve def. schema #120
Conversation
57925a0
to
98d7c3f
Compare
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
6e420b9
to
2c6e808
Compare
Signed-off-by: Todd Baert <[email protected]>
4cb07fe
to
005112a
Compare
Signed-off-by: Todd Baert <[email protected]>
VSCode supports a few additional properties like https://code.visualstudio.com/docs/languages/json#_use-rich-formatting-in-hovers |
Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: Todd Baert <[email protected]>
Seems like "defaultSnippets" also is an interesting non-standard addition it supports. |
Marking this draft for a bit because there's a few additions I want to make. |
Signed-off-by: Todd Baert <[email protected]>
Wow, that's an interesting feature! |
df6c094
to
69e4f99
Compare
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
@beeme1mr @Kavindu-Dodan I've added a bunch of tests. There was already some really nice testing implemented that simply iterates over a directory of definitions expected to fail and definitions expected to pass, so I just added a bunch of each! @beeme1mr I've also changed the defaults for boolean, and used |
@@ -4,3 +4,6 @@ import _ "embed" | |||
|
|||
//go:embed flagd-definitions.json | |||
var FlagdDefinitions string | |||
|
|||
//go:embed targeting.json | |||
var Targeting string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we export a const for the Targeting
schema as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. We should follow up and add validations in flagd for flag parsing 1
Footnotes
json/flagd_definitions_test.go
Outdated
schemaLoader = gojsonschema.NewSchemaLoader() | ||
schemaLoader.AddSchemas(gojsonschema.NewStringLoader(flagd_definitions.Targeting)) | ||
var err error | ||
s, err = schemaLoader.Compile(gojsonschema.NewStringLoader(flagd_definitions.FlagdDefinitions)) | ||
if err != nil { | ||
s := fmt.Errorf("err: %v", err) | ||
log.Fatal(s) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kavindu-Dodan you asked about this... this is how we can directly import schemas in Go (notice I import the referenced ($ref
) schema first, and then the root schema). This means no actual http requests will be made, the schemas are cached and referenced by their $id
. In most prod systems, this is how it's done - few servers or libraries will actually make HTTP requests for schemas, that's typically more of a development feature (like for IDEs).
See this link:
Even though schemas are identified by URIs, those identifiers are not necessarily network-addressable. They are just identifiers. Generally, implementations don't make HTTP requests (https://) or read from the file system (file://) to fetch schemas. Instead, they provide a way to load schemas into an internal schema database. When a schema is referenced by it's URI identifier, the schema is retrieved from the internal schema database.
cc @beeme1mr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I improved some var-names here since I made this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even consider this but it's definitely good to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thank you for the link and the comment. I thought this to be a valid URL hence my doubt :)
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work 👏
Added few suggestions but I am approving this anyway.
Co-authored-by: Kavindu Dodanduwa <[email protected]> Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
🤖 I have created a release *beep* *boop* --- <details><summary>json/json-schema: 0.1.2</summary> ## [0.1.2](json/json-schema-v0.1.1...json/json-schema-v0.1.2) (2024-01-08) ### ✨ New Features * add targeting schema, improve def. schema ([#120](#120)) ([6041fc7](6041fc7)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR:
sem_ver
,fractional
,starts/ends_with
) are fully validated$evalutators
validatedI've also added a bunch of positive and negative tests.
For a preview, add
"$schema": "https://deploy-preview-1115--polite-licorice-3db33c.netlify.app/schema/v0/flagd-definitions.json"
as a sibling to"flags"
in your flagd config.Closes: #115
.yaml
files are the source of truth; the CI checks that the json is consistent with them.