mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
522 adding swagger doc directly to repo instead of getting it from the internet
This commit is contained in:
parent
d5778e3815
commit
aec7a78822
2 changed files with 97416 additions and 21 deletions
97413
data/swaggerDoc.go
Normal file
97413
data/swaggerDoc.go
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,13 +1,13 @@
|
||||||
package policy
|
package policy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"compress/gzip"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/nirmata/kyverno/data"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/nirmata/kyverno/pkg/engine"
|
"github.com/nirmata/kyverno/pkg/engine"
|
||||||
|
@ -138,26 +138,8 @@ func setValidationGlobalState() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSchemaDocument() (*openapi_v2.Document, error) {
|
func getSchemaDocument() (*openapi_v2.Document, error) {
|
||||||
docReq, _ := http.NewRequest("GET", "https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json", nil)
|
|
||||||
docReq.Header.Set("accept-encoding", "gzip")
|
|
||||||
doc, err := http.DefaultClient.Do(docReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("Could not fetch openapi document from the internet, underlying error : %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
gzipReader, err := gzip.NewReader(doc.Body)
|
|
||||||
defer func() {
|
|
||||||
err := gzipReader.Close()
|
|
||||||
if err != nil {
|
|
||||||
glog.V(4).Info("Could not close gzip reader")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var spec yaml.MapSlice
|
var spec yaml.MapSlice
|
||||||
err = yaml.NewDecoder(gzipReader).Decode(&spec)
|
err := yaml.Unmarshal([]byte(data.SwaggerDoc), &spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue