rebase: update to latest snapshotter

this commit update the snapshotter client to v6.1.0

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2022-11-11 09:36:17 +05:30
committed by mergify[bot]
parent 8b078f1a11
commit c9ccbf29bb
115 changed files with 2526 additions and 10113 deletions

View File

@ -46,8 +46,23 @@ func (schema *Schema) describeSchema(indent string) string {
if schema.Schema != nil {
result += indent + "$schema: " + *(schema.Schema) + "\n"
}
if schema.ReadOnly != nil && *schema.ReadOnly {
result += indent + fmt.Sprintf("readOnly: %+v\n", *(schema.ReadOnly))
}
if schema.WriteOnly != nil && *schema.WriteOnly {
result += indent + fmt.Sprintf("writeOnly: %+v\n", *(schema.WriteOnly))
}
if schema.ID != nil {
result += indent + "id: " + *(schema.ID) + "\n"
switch strings.TrimSuffix(*schema.Schema, "#") {
case "http://json-schema.org/draft-04/schema#":
fallthrough
case "#":
fallthrough
case "":
result += indent + "id: " + *(schema.ID) + "\n"
default:
result += indent + "$id: " + *(schema.ID) + "\n"
}
}
if schema.MultipleOf != nil {
result += indent + fmt.Sprintf("multipleOf: %+v\n", *(schema.MultipleOf))

View File

@ -23,9 +23,11 @@ import "gopkg.in/yaml.v3"
// All fields are pointers and are nil if the associated values
// are not specified.
type Schema struct {
Schema *string // $schema
ID *string // id keyword used for $ref resolution scope
Ref *string // $ref, i.e. JSON Pointers
Schema *string // $schema
ID *string // id keyword used for $ref resolution scope
Ref *string // $ref, i.e. JSON Pointers
ReadOnly *bool
WriteOnly *bool
// http://json-schema.org/latest/json-schema-validation.html
// 5.1. Validation keywords for numeric instances (number and integer)

View File

@ -165,7 +165,6 @@ func NewSchemaFromObject(jsonData *yaml.Node) *Schema {
default:
fmt.Printf("schemaValue: unexpected node %+v\n", jsonData)
return nil
}
return nil

View File

@ -16,6 +16,7 @@ package jsonschema
import (
"fmt"
"strings"
"gopkg.in/yaml.v3"
)
@ -33,7 +34,11 @@ func renderMappingNode(node *yaml.Node, indent string) (result string) {
value := node.Content[i+1]
switch value.Kind {
case yaml.ScalarNode:
result += "\"" + value.Value + "\""
if value.Tag == "!!bool" {
result += value.Value
} else {
result += "\"" + value.Value + "\""
}
case yaml.MappingNode:
result += renderMappingNode(value, innerIndent)
case yaml.SequenceNode:
@ -58,7 +63,11 @@ func renderSequenceNode(node *yaml.Node, indent string) (result string) {
item := node.Content[i]
switch item.Kind {
case yaml.ScalarNode:
result += innerIndent + "\"" + item.Value + "\""
if item.Tag == "!!bool" {
result += innerIndent + item.Value
} else {
result += innerIndent + "\"" + item.Value + "\""
}
case yaml.MappingNode:
result += innerIndent + renderMappingNode(item, innerIndent) + ""
default:
@ -260,11 +269,26 @@ func (schema *Schema) nodeValue() *yaml.Node {
content = appendPair(content, "title", nodeForString(*schema.Title))
}
if schema.ID != nil {
content = appendPair(content, "id", nodeForString(*schema.ID))
switch strings.TrimSuffix(*schema.Schema, "#") {
case "http://json-schema.org/draft-04/schema":
fallthrough
case "#":
fallthrough
case "":
content = appendPair(content, "id", nodeForString(*schema.ID))
default:
content = appendPair(content, "$id", nodeForString(*schema.ID))
}
}
if schema.Schema != nil {
content = appendPair(content, "$schema", nodeForString(*schema.Schema))
}
if schema.ReadOnly != nil && *schema.ReadOnly {
content = appendPair(content, "readOnly", nodeForBoolean(*schema.ReadOnly))
}
if schema.WriteOnly != nil && *schema.WriteOnly {
content = appendPair(content, "writeOnly", nodeForBoolean(*schema.WriteOnly))
}
if schema.Type != nil {
content = appendPair(content, "type", schema.Type.nodeValue())
}