mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
cache http client in http registry
This commit is contained in:
parent
9d7a79b253
commit
44710f9053
1 changed files with 4 additions and 4 deletions
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
type KubernetesRegistry struct {
|
||||
http *http.Transport
|
||||
c *http.Client
|
||||
schemaPathTemplate string
|
||||
strict bool
|
||||
}
|
||||
|
|
@ -29,12 +29,13 @@ func newHTTPRegistry(schemaPathTemplate string, strict bool, skipTLS bool) *Kube
|
|||
IdleConnTimeout: 3 * time.Second,
|
||||
DisableCompression: true,
|
||||
}
|
||||
|
||||
if skipTLS {
|
||||
reghttp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
}
|
||||
|
||||
return &KubernetesRegistry{
|
||||
http: reghttp,
|
||||
c: &http.Client{Transport: reghttp},
|
||||
schemaPathTemplate: schemaPathTemplate,
|
||||
strict: strict,
|
||||
}
|
||||
|
|
@ -46,8 +47,7 @@ func (r KubernetesRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8s
|
|||
return nil, err
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: r.http}
|
||||
resp, err := client.Get(url)
|
||||
resp, err := r.c.Get(url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed downloading schema at %s: %s", url, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue