MCPcopy Create free account
hub / github.com/apache/camel-k / newSource

Function newSource

pkg/cmd/source/source.go:48–70  ·  view source on GitHub ↗

newSource creates a source using the content provider function.

(location string, compress bool, loadContent func() ([]byte, error))

Source from the content-addressed store, hash-verified

46
47// newSource creates a source using the content provider function.
48func newSource(location string, compress bool, loadContent func() ([]byte, error)) (Source, error) {
49 // strip query part from location if any
50 locPath := util.SubstringBefore(location, "?")
51 if locPath == "" {
52 locPath = location
53 }
54 src := Source{
55 Name: filepath.Base(locPath),
56 Origin: location,
57 Location: location,
58 Compress: compress,
59 }
60
61 content, err := loadContent()
62 if err != nil {
63 return Source{}, err
64 }
65 if err := src.setContent(content); err != nil {
66 return Source{}, err
67 }
68
69 return src, nil
70}
71
72func (s *Source) setContent(content []byte) error {
73 if s.Compress {

Callers 2

ResolveFunction · 0.85
resolveLocalFunction · 0.85

Calls 2

setContentMethod · 0.95
SubstringBeforeFunction · 0.92

Tested by

no test coverage detected