summaryrefslogtreecommitdiff
path: root/pkg/network
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/network')
-rw-r--r--pkg/network/network.go18
1 files changed, 17 insertions, 1 deletions
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
+}