mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-10-19 05:39:51 +00:00
91774fc936
Uses github.com/libopenstorage/secrets to communicate with Vault. This removes the need for maintaining our own limited Vault APIs. By adding the new dependency, several other packages got updated in the process. Unused indirect dependencies have been removed from go.mod. Signed-off-by: Niels de Vos <ndevos@redhat.com>
37 lines
840 B
Go
37 lines
840 B
Go
// +build darwin dragonfly freebsd netbsd openbsd
|
|
|
|
package sockaddr
|
|
|
|
import "os/exec"
|
|
|
|
var cmds map[string][]string = map[string][]string{
|
|
"route": {"/sbin/route", "-n", "get", "default"},
|
|
}
|
|
|
|
type routeInfo struct {
|
|
cmds map[string][]string
|
|
}
|
|
|
|
// NewRouteInfo returns a BSD-specific implementation of the RouteInfo
|
|
// interface.
|
|
func NewRouteInfo() (routeInfo, error) {
|
|
return routeInfo{
|
|
cmds: cmds,
|
|
}, nil
|
|
}
|
|
|
|
// GetDefaultInterfaceName returns the interface name attached to the default
|
|
// route on the default interface.
|
|
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
|
|
out, err := exec.Command(cmds["route"][0], cmds["route"][1:]...).Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
var ifName string
|
|
if ifName, err = parseDefaultIfNameFromRoute(string(out)); err != nil {
|
|
return "", err
|
|
}
|
|
return ifName, nil
|
|
}
|