| 241 | } |
| 242 | |
| 243 | func 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. |