Skip to content

Commit

Permalink
Merge pull request #542 from replicatedhq/schemagen-quotedbool
Browse files Browse the repository at this point in the history
Schemagen for QuotedBools
  • Loading branch information
emosbaugh committed May 14, 2020
2 parents f5a74c9 + e733e4e commit 1539e16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion kotskinds/schemagen/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ func generateSchemaFromCRD(crd []byte, outfile string) error {
// whoa now
// working around the fact that controller-gen doesn't have tags to generate oneOf schemas, so this is hacky.
// going to work to add an issue there to support and if they accept, this terrible thing can go away
boolStringed := strings.ReplaceAll(string(b), `"type": "BoolString"`, `"oneOf": [{"type": "string"},{"type": "boolean"}]`)
replacer := strings.NewReplacer(
`"type": "BoolString"`, `"oneOf": [{"type": "string"},{"type": "boolean"}]`,
`"type": "QuotedBool"`, `"oneOf": [{"type": "string"},{"type": "boolean"}]`,
)
boolStringed := replacer.Replace(string(b))

err = ioutil.WriteFile(outfile, []byte(boolStringed), 0644)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion kotskinds/schemas/config-kots-v1beta1.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
},
"when": {
"description": "QuotedBool is a string type that can also unmarshal raw yaml bools.",
"type": "QuotedBool"
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"write_once": {
"type": "boolean"
Expand Down

0 comments on commit 1539e16

Please sign in to comment.