diff options
Diffstat (limited to 'config/util.go')
-rw-r--r-- | config/util.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/config/util.go b/config/util.go index 13f1fa77..36999411 100644 --- a/config/util.go +++ b/config/util.go @@ -18,12 +18,28 @@ package config import ( "fmt" "net" + "path/filepath" "regexp" "strconv" "github.com/osrg/gobgp/packet/bgp" ) +// Returns config file type by retrieving extension from the given path. +// If no corresponding type found, returns the given def as the default value. +func detectConfigFileType(path, def string) string { + switch ext := filepath.Ext(path); ext { + case ".toml": + return "toml" + case ".yaml", ".yml": + return "yaml" + case ".json": + return "json" + default: + return def + } +} + func IsConfederationMember(g *Global, p *Neighbor) bool { if p.Config.PeerAs != g.Config.As { for _, member := range g.Confederation.Config.MemberAsList { |