Skip to content

Commit

Permalink
fix compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Janiszewski <[email protected]>
  • Loading branch information
janisz committed Jan 16, 2024
1 parent 94fdbd0 commit 96b6435
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/framework/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *runner) Require() *require.Assertions {
}

func (r *runner) readAndValidateYAML(fileName, fileContents string, resources openapi.Resources) []unstructured.Unstructured {
validator := validation.NewSchemaValidation(resources)
validator := validation.NewSchemaValidation(OpenAPIResourcesGetter(resources))

yamlReader := yaml.NewYAMLReader(bufio.NewReader(strings.NewReader(fileContents)))

Expand Down
15 changes: 15 additions & 0 deletions pkg/framework/util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package framework

import (
"k8s.io/kubectl/pkg/util/openapi"
"os"

"github.com/pkg/errors"
Expand All @@ -25,3 +26,17 @@ func unmarshalYamlFromFileStrict(filename string, out interface{}) error {
}
return nil
}

type openAPIResourcesGetter struct {
resources openapi.Resources
}

func (o openAPIResourcesGetter) OpenAPISchema() (openapi.Resources, error) {
return o.resources, nil
}

// OpenAPIResourcesGetter returns resources wrapped in a simple implementation of openapi.OpenAPIResourcesGetter
// that returns a fixed set of resources.
func OpenAPIResourcesGetter(resources openapi.Resources) openapi.OpenAPIResourcesGetter {
return openAPIResourcesGetter{resources: resources}
}

0 comments on commit 96b6435

Please sign in to comment.