Initialise custom adapters based on current config
(git Env, m *concreteManifest)
| 362 | |
| 363 | // Initialise custom adapters based on current config |
| 364 | func configureCustomAdapters(git Env, m *concreteManifest) { |
| 365 | configureDefaultCustomAdapters(git, m) |
| 366 | |
| 367 | pathRegex := regexp.MustCompile(`lfs.customtransfer.([^.]+).path`) |
| 368 | for k, _ := range git.All() { |
| 369 | match := pathRegex.FindStringSubmatch(k) |
| 370 | if match == nil { |
| 371 | continue |
| 372 | } |
| 373 | |
| 374 | name := match[1] |
| 375 | path, _ := git.Get(k) |
| 376 | // retrieve other values |
| 377 | args, _ := git.Get(fmt.Sprintf("lfs.customtransfer.%s.args", name)) |
| 378 | concurrent := git.Bool(fmt.Sprintf("lfs.customtransfer.%s.concurrent", name), true) |
| 379 | direction, _ := git.Get(fmt.Sprintf("lfs.customtransfer.%s.direction", name)) |
| 380 | if len(direction) == 0 { |
| 381 | direction = "both" |
| 382 | } else { |
| 383 | direction = strings.ToLower(direction) |
| 384 | } |
| 385 | |
| 386 | // Separate closure for each since we need to capture vars above |
| 387 | newfunc := func(name string, dir Direction) Adapter { |
| 388 | standalone := m.standaloneTransferAgent != "" |
| 389 | return newCustomAdapter(m.fs, name, dir, path, args, concurrent, standalone) |
| 390 | } |
| 391 | |
| 392 | if direction == "download" || direction == "both" { |
| 393 | m.RegisterNewAdapterFunc(name, Download, newfunc) |
| 394 | } |
| 395 | if direction == "upload" || direction == "both" { |
| 396 | m.RegisterNewAdapterFunc(name, Upload, newfunc) |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | type customAdapterConfig struct { |
| 402 | AdapterConfig |
no test coverage detected