Merge pull request #3617 from natasha41575/UseCustomOpenApiSchema

add openapi/path field to use custom openapi schema document
This commit is contained in:
Kubernetes Prow Robot
2021-02-24 15:03:24 -08:00
committed by GitHub
7 changed files with 92898 additions and 94 deletions

View File

@@ -6,6 +6,7 @@ package target
import (
"encoding/json"
"fmt"
"path/filepath"
"strings"
"github.com/pkg/errors"
@@ -377,10 +378,17 @@ func (kt *KustTarget) accumulateDirectory(
return nil, errors.Wrapf(
err, "couldn't make target for path '%s'", ldr.Root())
}
err = openapi.SetSchemaVersion(subKt.Kustomization().OpenAPI, false)
var bytes []byte
path := ldr.Root()
if openApiPath, exists := subKt.Kustomization().OpenAPI["path"]; exists {
bytes, err = ldr.Load(filepath.Join(path, openApiPath))
if err != nil {
return nil, err
}
}
err = openapi.SetSchema(subKt.Kustomization().OpenAPI, bytes, false)
if err != nil {
return nil, errors.Wrapf(
err, "couldn't set openapi version for path '%s'", ldr.Root())
return nil, err
}
if isComponent && subKt.kustomization.Kind != types.ComponentKind {
return nil, fmt.Errorf(