mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 02:47:01 +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 {
|
type KubernetesRegistry struct {
|
||||||
http *http.Transport
|
c *http.Client
|
||||||
schemaPathTemplate string
|
schemaPathTemplate string
|
||||||
strict bool
|
strict bool
|
||||||
}
|
}
|
||||||
|
|
@ -29,12 +29,13 @@ func newHTTPRegistry(schemaPathTemplate string, strict bool, skipTLS bool) *Kube
|
||||||
IdleConnTimeout: 3 * time.Second,
|
IdleConnTimeout: 3 * time.Second,
|
||||||
DisableCompression: true,
|
DisableCompression: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if skipTLS {
|
if skipTLS {
|
||||||
reghttp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
reghttp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &KubernetesRegistry{
|
return &KubernetesRegistry{
|
||||||
http: reghttp,
|
c: &http.Client{Transport: reghttp},
|
||||||
schemaPathTemplate: schemaPathTemplate,
|
schemaPathTemplate: schemaPathTemplate,
|
||||||
strict: strict,
|
strict: strict,
|
||||||
}
|
}
|
||||||
|
|
@ -46,8 +47,7 @@ func (r KubernetesRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8s
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{Transport: r.http}
|
resp, err := r.c.Get(url)
|
||||||
resp, err := client.Get(url)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed downloading schema at %s: %s", url, err)
|
return nil, fmt.Errorf("failed downloading schema at %s: %s", url, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue