Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Sep 5, 2024
1 parent b8d77e7 commit ec328d3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 60 deletions.
87 changes: 38 additions & 49 deletions bundle/generated/jsonschema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions bundle/internal/schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
}

// The variables block in a target override allows for directly specifying
// the value if it is a primitive type.
// the value of the variable.
if typ == reflect.TypeOf(variable.TargetVariable{}) {
return jsonschema.Schema{
AnyOf: []jsonschema.Schema{s,
{Type: jsonschema.StringType},
{Type: jsonschema.BooleanType},
{Type: jsonschema.IntegerType},
{Type: jsonschema.NumberType},
AnyOf: []jsonschema.Schema{
// We keep the original schema so that autocomplete suggestions
// continue to work.
s,
// All values are valid for a variable value, be it primitive types
// like string/bool or complex ones like objects/arrays. Thus we override
// the schema to allow all valid JSON values.
{},
},
}
}
Expand All @@ -38,16 +41,19 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
case jsonschema.ArrayType, jsonschema.ObjectType:
// arrays and objects can have complex variable values specified.
return jsonschema.Schema{
AnyOf: []jsonschema.Schema{s, {
Type: jsonschema.StringType,
Pattern: interpolationPattern("var"),
}},
AnyOf: []jsonschema.Schema{
s,
{
Type: jsonschema.StringType,
Pattern: interpolationPattern("var"),
}},
}
case jsonschema.IntegerType, jsonschema.NumberType, jsonschema.BooleanType:
// primitives can have variable values, or references like ${bundle.xyz}
// or ${workspace.xyz}
return jsonschema.Schema{
AnyOf: []jsonschema.Schema{s,
AnyOf: []jsonschema.Schema{
s,
{Type: jsonschema.StringType, Pattern: interpolationPattern("resources")},
{Type: jsonschema.StringType, Pattern: interpolationPattern("bundle")},
{Type: jsonschema.StringType, Pattern: interpolationPattern("workspace")},
Expand Down

0 comments on commit ec328d3

Please sign in to comment.