MCPcopy Create free account
hub / github.com/AdRoll/baker / processList

Method processList

input/list.go:262–379  ·  view source on GitHub ↗
(fn string)

Source from the content-addressed store, hash-verified

260}
261
262func (s *List) processList(fn string) error {
263 if fn == "-" {
264 s.processListFile(stdin)
265 return nil
266 }
267
268 u, err := url.Parse(fn)
269 if err != nil {
270 // NOTE: raw paths are parsed with u.Scheme=""
271 return err
272 }
273
274 switch u.Scheme {
275 case "", "file":
276 // A list file on the local disk can be either a real file
277 // or a directory (whose contents will be processed)
278 path := filepath.Join(u.Host, u.Path) // On Windows Host contains the drive letter
279 if fi, err := os.Stat(path); err != nil {
280 return err
281 } else if fi.IsDir() {
282 return filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
283 if err == nil && s.matchPath.MatchString(p) {
284 s.ci.ProcessFile(p)
285 }
286 return nil
287 })
288 } else {
289 f, err := os.Open(path)
290 if err != nil {
291 return err
292 }
293 s.processListFile(f)
294 f.Close()
295 return nil
296 }
297
298 case "s3":
299 if u.Path[len(u.Path)-1:] == "/" {
300 // ListObjectsV2Input prefix must not start with /
301 prefix := strings.TrimLeft(u.Path, "/")
302
303 paths := make(chan string)
304 errCh := make(chan error)
305
306 go func() {
307 defer close(paths)
308
309 var nextToken *string
310 input := &s3.ListObjectsV2Input{
311 Bucket: aws.String(u.Host),
312 Prefix: aws.String(prefix),
313 MaxKeys: aws.Int64(1000), // 1000 is the max value
314 }
315 for {
316 if nextToken != nil {
317 input.ContinuationToken = nextToken
318 }
319

Callers 1

processFileOrListMethod · 0.95

Calls 7

processListFileMethod · 0.95
httpGetFunction · 0.85
ProcessFileMethod · 0.80
GetObjectMethod · 0.80
ParseMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected