-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate generated schemas in generator script (#6385)
* fix build --push=false for missing kubeconfig * Fixed log ordering per PR comment * Added validation to schema generation * Added validation to schema generation * Updated validate function * Refactor validate method * Updated error logic * Fix linter error
- Loading branch information
Showing
7 changed files
with
233 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright 2021 The Skaffold Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package latest | ||
|
||
// TestStruct for testing the schema generator. | ||
type TestStruct struct { | ||
|
||
// RequiredField should be required | ||
RequiredField string `yaml:"reqField" yamltags:"required"` | ||
|
||
// AnotherField has reference to InlineStruct | ||
AnotherField *InlineStruct `yaml:"anotherField"` | ||
} | ||
|
||
// AnotherTestStruct for testing the schema s generator. | ||
type AnotherTestStruct struct { | ||
InlineStruct `yaml:"inline" yamltags:"skipTrim"` | ||
} | ||
|
||
// InlineStruct is embedded inline into TestStruct | ||
type InlineStruct struct { | ||
|
||
// Field1 should be the first choice | ||
Field1 string `yaml:"f1"` | ||
|
||
// Field2 should be the second choice | ||
Field2 string `yaml:"f2"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"type": "object", | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/TestStruct" | ||
} | ||
], | ||
"$schema": "http://json-schema-org/draft-07/schema#", | ||
"definitions": { | ||
"AnotherTestStruct": { | ||
"properties": { | ||
"f1": { | ||
"type": "string", | ||
"description": "should be the first choice", | ||
"x-intellij-html-description": "should be the first choice" | ||
}, | ||
"f2": { | ||
"type": "string", | ||
"description": "should be the second choice", | ||
"x-intellij-html-description": "should be the second choice" | ||
} | ||
}, | ||
"preferredOrder": [ | ||
"f1", | ||
"f2" | ||
], | ||
"type": "object", | ||
"description": "for testing the schema s generator.", | ||
"x-intellij-html-description": "for testing the schema s generator." | ||
}, | ||
"InlineStruct": { | ||
"properties": { | ||
"f1": { | ||
"type": "string", | ||
"description": "should be the first choice", | ||
"x-intellij-html-description": "should be the first choice" | ||
}, | ||
"f2": { | ||
"type": "string", | ||
"description": "should be the second choice", | ||
"x-intellij-html-description": "should be the second choice" | ||
} | ||
}, | ||
"preferredOrder": [ | ||
"f1", | ||
"f2" | ||
], | ||
"additionalProperties": false, | ||
"type": "object", | ||
"description": "embedded inline into TestStruct", | ||
"x-intellij-html-description": "embedded inline into TestStruct" | ||
}, | ||
"TestStruct": { | ||
"required": [ | ||
"reqField" | ||
], | ||
"properties": { | ||
"anotherField": { | ||
"$ref": "#/definitions/InlineStruct", | ||
"description": "has reference to InlineStruct", | ||
"x-intellij-html-description": "has reference to InlineStruct" | ||
}, | ||
"reqField": { | ||
"type": "string", | ||
"description": "should be required", | ||
"x-intellij-html-description": "should be required" | ||
} | ||
}, | ||
"preferredOrder": [ | ||
"reqField", | ||
"anotherField" | ||
], | ||
"additionalProperties": false, | ||
"type": "object", | ||
"description": "for testing the schema generator.", | ||
"x-intellij-html-description": "for testing the schema generator." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2021 The Skaffold Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package latest | ||
|
||
// TestStruct for testing the schema generator. | ||
type TestStruct struct { | ||
|
||
// RequiredField should be required | ||
RequiredField string `yaml:"reqField" yamltags:"required"` | ||
|
||
// AnotherField has reference to InlineStruct | ||
AnotherField *InlineStruct `yaml:"anotherField"` | ||
} | ||
|
||
// AnotherTestStruct for testing the schema s generator. | ||
type AnotherTestStruct struct { | ||
// Not adding yamltags:"skipTrim" causes InlineStruct to be removed from definitions | ||
// This breaks the TestStruct reference above | ||
InlineStruct `yaml:"inline"` | ||
} | ||
|
||
// InlineStruct is embedded inline into TestStruct | ||
type InlineStruct struct { | ||
|
||
// Field1 should be the first choice | ||
Field1 string `yaml:"f1"` | ||
|
||
// Field2 should be the second choice | ||
Field2 string `yaml:"f2"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters