MCPcopy
hub / github.com/yannh/kubeconform / openInput

Function openInput

openapi2jsonschema-go/openapi2jsonschema.go:243–262  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

241}
242
243func openInput(path string) (io.ReadCloser, error) {
244 if strings.HasPrefix(path, "http") {
245 client := http.DefaultClient
246 if os.Getenv("DISABLE_SSL_CERT_VALIDATION") != "" {
247 client = &http.Client{Transport: &http.Transport{
248 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
249 }}
250 }
251 resp, err := client.Get(path)
252 if err != nil {
253 return nil, err
254 }
255 if resp.StatusCode >= 400 {
256 resp.Body.Close()
257 return nil, fmt.Errorf("HTTP %d fetching %s", resp.StatusCode, path)
258 }
259 return resp.Body, nil
260 }
261 return os.Open(path)
262}
263
264// process consumes one CRD source (file or URL) and writes one JSON schema per
265// version found, mirroring the original Python control flow.

Callers 1

processFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected