mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 02:20:53 +00:00
support yaml formatted openapi schema (#4017)
* support yaml formatted openapi schema * suggested changes
This commit is contained in:
@@ -17,6 +17,11 @@ func writeTestSchema(th kusttest_test.Harness, filepath string) {
|
||||
th.WriteF(filepath+"mycrd_schema.json", string(bytes))
|
||||
}
|
||||
|
||||
func writeTestSchemaYaml(th kusttest_test.Harness, filepath string) {
|
||||
bytes, _ := ioutil.ReadFile("testdata/customschema.yaml")
|
||||
th.WriteF(filepath+"mycrd_schema.yaml", string(bytes))
|
||||
}
|
||||
|
||||
func writeCustomResource(th kusttest_test.Harness, filepath string) {
|
||||
th.WriteF(filepath, `
|
||||
apiVersion: example.com/v1alpha1
|
||||
@@ -103,6 +108,21 @@ openapi:
|
||||
th.AssertActualEqualsExpected(m, patchedCustomResource)
|
||||
}
|
||||
|
||||
func TestCustomOpenApiFieldYaml(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
resources:
|
||||
- mycrd.yaml
|
||||
openapi:
|
||||
path: mycrd_schema.yaml
|
||||
`+customSchemaPatch)
|
||||
writeCustomResource(th, "mycrd.yaml")
|
||||
writeTestSchemaYaml(th, "./")
|
||||
openapi.ResetOpenAPI()
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, patchedCustomResource)
|
||||
}
|
||||
|
||||
// Error if user tries to specify both builtin version
|
||||
// and custom schema
|
||||
func TestCustomOpenApiFieldBothPathAndVersion(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user