MCPcopy Create free account
hub / github.com/cloudbase/garm / parseAndReadCABundle

Function parseAndReadCABundle

cmd/garm-cli/cmd/github_endpoints.go:230–250  ·  view source on GitHub ↗
(bundlePath string)

Source from the content-addressed store, hash-verified

228}
229
230func parseAndReadCABundle(bundlePath string) ([]byte, error) {
231 if bundlePath == "" {
232 return nil, nil
233 }
234
235 if _, err := os.Stat(bundlePath); os.IsNotExist(err) {
236 return nil, fmt.Errorf("CA cert file not found: %s", bundlePath)
237 }
238 contents, err := os.ReadFile(bundlePath)
239 if err != nil {
240 return nil, err
241 }
242 pemBlock, _ := pem.Decode(contents)
243 if pemBlock == nil {
244 return nil, fmt.Errorf("failed to decode PEM block")
245 }
246 if _, err := x509.ParseCertificates(pemBlock.Bytes); err != nil {
247 return nil, fmt.Errorf("failed to parse CA cert bundle: %w", err)
248 }
249 return contents, nil
250}
251
252func parseCreateParams() (params.CreateGithubEndpointParams, error) {
253 certBundleBytes, err := parseAndReadCABundle(endpointCACertPath)

Callers 6

init.goFile · 0.85
controller.goFile · 0.85
parseCreateParamsFunction · 0.85
gitea_endpoints.goFile · 0.85
parseGiteaCreateParamsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected