add openapi/path field to use custom openapi schema document

This commit is contained in:
Natasha Sarkar
2021-02-17 18:08:27 -08:00
parent 99e82890e1
commit 7dd0ade0f9
6 changed files with 92996 additions and 19 deletions

View File

@@ -5,6 +5,7 @@ package krusty
import (
"fmt"
"path/filepath"
"sigs.k8s.io/kustomize/api/builtins"
"sigs.k8s.io/kustomize/api/filesys"
@@ -73,7 +74,14 @@ func (b *Kustomizer) Run(
if err != nil {
return nil, err
}
err = openapi.SetSchemaVersion(kt.Kustomization().OpenAPI, true)
var bytes []byte
if openApiPath, exists := kt.Kustomization().OpenAPI["path"]; exists {
bytes, err = ldr.Load(filepath.Join(ldr.Root(), openApiPath))
if err != nil {
return nil, err
}
}
err = openapi.SetSchema(kt.Kustomization().OpenAPI, bytes, true)
if err != nil {
return nil, err
}