From c3af2faab2dde219b286800a34552523a1d3f9e3 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Wed, 13 May 2020 14:24:59 -0500 Subject: network compatibility endpoints for API add endpoints for networking compatibility with the API. Signed-off-by: Brent Baude --- pkg/network/network.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'pkg/network') diff --git a/pkg/network/network.go b/pkg/network/network.go index 5e9062019..526ee92d8 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -13,8 +13,11 @@ import ( "github.com/sirupsen/logrus" ) +// DefaultNetworkDriver is the default network type used +var DefaultNetworkDriver string = "bridge" + // SupportedNetworkDrivers describes the list of supported drivers -var SupportedNetworkDrivers = []string{"bridge"} +var SupportedNetworkDrivers = []string{DefaultNetworkDriver} // IsSupportedDriver checks if the user provided driver is supported func IsSupportedDriver(driver string) error { @@ -191,3 +194,16 @@ func InspectNetwork(config *config.Config, name string) (map[string]interface{}, err = json.Unmarshal(b, &rawList) return rawList, err } + +// Exists says whether a given network exists or not; it meant +// specifically for restful reponses so 404s can be used +func Exists(config *config.Config, name string) (bool, error) { + _, err := ReadRawCNIConfByName(config, name) + if err != nil { + if errors.Cause(err) == ErrNetworkNotFound { + return false, nil + } + return false, err + } + return true, nil +} -- cgit v1.2.3-54-g00ecf