mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
Use httploader to validate HTTP references
This commit is contained in:
parent
153d5f87fb
commit
682ca5c9e2
3 changed files with 40 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
|
||||
jsonschema "github.com/santhosh-tekuri/jsonschema/v5"
|
||||
_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
|
||||
"github.com/yannh/kubeconform/pkg/cache"
|
||||
"github.com/yannh/kubeconform/pkg/registry"
|
||||
"github.com/yannh/kubeconform/pkg/resource"
|
||||
|
|
|
|||
38
vendor/github.com/santhosh-tekuri/jsonschema/v5/httploader/httploader.go
generated
vendored
Normal file
38
vendor/github.com/santhosh-tekuri/jsonschema/v5/httploader/httploader.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// Package httploader implements loader.Loader for http/https url.
|
||||
//
|
||||
// The package is typically only imported for the side effect of
|
||||
// registering its Loaders.
|
||||
//
|
||||
// To use httploader, link this package into your program:
|
||||
//
|
||||
// import _ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
|
||||
package httploader
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/santhosh-tekuri/jsonschema/v5"
|
||||
)
|
||||
|
||||
// Client is the default HTTP Client used to Get the resource.
|
||||
var Client = http.DefaultClient
|
||||
|
||||
// Load loads resource from given http(s) url.
|
||||
func Load(url string) (io.ReadCloser, error) {
|
||||
resp, err := Client.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
_ = resp.Body.Close()
|
||||
return nil, fmt.Errorf("%s returned status code %d", url, resp.StatusCode)
|
||||
}
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
jsonschema.Loaders["http"] = Load
|
||||
jsonschema.Loaders["https"] = Load
|
||||
}
|
||||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
|
@ -1,6 +1,7 @@
|
|||
# github.com/santhosh-tekuri/jsonschema/v5 v5.1.1
|
||||
## explicit; go 1.15
|
||||
github.com/santhosh-tekuri/jsonschema/v5
|
||||
github.com/santhosh-tekuri/jsonschema/v5/httploader
|
||||
# gopkg.in/yaml.v2 v2.4.0
|
||||
## explicit; go 1.15
|
||||
gopkg.in/yaml.v2
|
||||
|
|
|
|||
Loading…
Reference in a new issue