backend.go 969 B

12345678910111213141516171819202122232425262728293031323334
  1. package network
  2. import (
  3. "fmt"
  4. "strings"
  5. "github.com/coreos/flannel/backend"
  6. "github.com/coreos/flannel/backend/alloc"
  7. "github.com/coreos/flannel/backend/awsvpc"
  8. "github.com/coreos/flannel/backend/gce"
  9. "github.com/coreos/flannel/backend/hostgw"
  10. "github.com/coreos/flannel/backend/udp"
  11. "github.com/coreos/flannel/backend/vxlan"
  12. "github.com/coreos/flannel/subnet"
  13. )
  14. func newBackend(sm subnet.Manager, network string, config *subnet.Config) (backend.Backend, error) {
  15. switch strings.ToLower(config.BackendType) {
  16. case "udp":
  17. return udp.New(sm, network, config), nil
  18. case "alloc":
  19. return alloc.New(sm, network), nil
  20. case "host-gw":
  21. return hostgw.New(sm, network), nil
  22. case "vxlan":
  23. return vxlan.New(sm, network, config), nil
  24. case "aws-vpc":
  25. return awsvpc.New(sm, network, config), nil
  26. case "gce":
  27. return gce.New(sm, network, config), nil
  28. default:
  29. return nil, fmt.Errorf("%v: '%v': unknown backend type", network, config.BackendType)
  30. }
  31. }