MCPcopy
hub / github.com/helmfile/helmfile / Parse

Function Parse

pkg/remote/remote.go:115–163  ·  view source on GitHub ↗
(goGetterSrc string)

Source from the content-addressed store, hash-verified

113}
114
115func Parse(goGetterSrc string) (*Source, error) {
116 items := strings.Split(goGetterSrc, "::")
117 var getter string
118 if len(items) == 2 {
119 getter = items[0]
120 goGetterSrc = items[1]
121 } else {
122 items = strings.Split(goGetterSrc, "://")
123
124 if len(items) == 2 {
125 return ParseNormal(goGetterSrc)
126 }
127 }
128
129 // Local absolute paths (e.g., C:\path on Windows, /path on Unix)
130 // are not remote URLs. Reject them before go-getter's url.Parse
131 // can misinterpret Windows drive letters as URL schemes.
132 if filepath.IsAbs(goGetterSrc) {
133 return nil, InvalidURLError{err: fmt.Sprintf("parse url: local absolute path is not a remote URL: %s", goGetterSrc)}
134 }
135
136 u, err := url.Parse(goGetterSrc)
137 if err != nil {
138 return nil, InvalidURLError{err: fmt.Sprintf("parse url: %v", err)}
139 }
140
141 if u.Scheme == "" {
142 return nil, InvalidURLError{err: fmt.Sprintf("parse url: missing scheme - probably this is a local file path? %s", goGetterSrc)}
143 }
144
145 pathComponents := strings.Split(u.Path, "@")
146 if len(pathComponents) != 2 {
147 dir := filepath.Dir(u.Path)
148 if len(dir) > 0 {
149 dir = dir[1:]
150 }
151 pathComponents = []string{dir, filepath.Base(u.Path)}
152 }
153
154 return &Source{
155 Getter: getter,
156 User: u.User.String(),
157 Scheme: u.Scheme,
158 Host: u.Host,
159 Dir: pathComponents[0],
160 File: pathComponents[1],
161 RawQuery: u.RawQuery,
162 }, nil
163}
164
165func ParseNormal(path string) (*Source, error) {
166 _, err := ParseNormalProtocol(path)

Callers 5

goGetterChartMethod · 0.92
TestParseFunction · 0.85
TestParse_WindowsFunction · 0.85
IsRemoteFunction · 0.85
FetchMethod · 0.85

Calls 3

ParseNormalFunction · 0.85
ParseMethod · 0.80
StringMethod · 0.80

Tested by 2

TestParseFunction · 0.68
TestParse_WindowsFunction · 0.68