summaryrefslogtreecommitdiff
path: root/pkg/network
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-05-13 14:24:59 -0500
committerBrent Baude <bbaude@redhat.com>2020-05-22 13:48:52 -0500
commitc3af2faab2dde219b286800a34552523a1d3f9e3 (patch)
treea9b1d4fbb6ad7c38bb43aa5a4cbea9d43eb935df /pkg/network
parenta6ee8bf2afccddcf8eb5d93e135e5b8b9e750259 (diff)
downloadpodman-c3af2faab2dde219b286800a34552523a1d3f9e3.tar.gz
podman-c3af2faab2dde219b286800a34552523a1d3f9e3.tar.bz2
podman-c3af2faab2dde219b286800a34552523a1d3f9e3.zip
network compatibility endpoints for API
add endpoints for networking compatibility with the API. Signed-off-by: Brent Baude <bbaude@redhat.com>
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
+}