MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / loadResourceFromURLOrEnv

Function loadResourceFromURLOrEnv

pkg/resourceloader/resourceloader.go:56–71  ·  view source on GitHub ↗
(resourcePath string)

Source from the content-addressed store, hash-verified

54}
55
56func loadResourceFromURLOrEnv(resourcePath string) ([]byte, error) {
57 parts := strings.SplitAfterN(resourcePath, "://", 2)
58 // If the path does not contain a scheme, it is considered a file path
59 if len(parts) != 2 {
60 return nil, &UnrecognizedSchemeError{Scheme: parts[0]}
61 }
62
63 switch parts[0] {
64 case "http://", "https://":
65 return loadFromURL(resourcePath)
66 case "env://":
67 return loadFromEnv(parts[1])
68 default:
69 return nil, &UnrecognizedSchemeError{Scheme: parts[0]}
70 }
71}
72
73// loadFromURL loads the content of a URL and returns it as a byte slice.
74func loadFromURL(url string) ([]byte, error) {

Callers 1

GetPathForResourceFunction · 0.85

Calls 2

loadFromURLFunction · 0.85
loadFromEnvFunction · 0.85

Tested by

no test coverage detected