diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-25 04:46:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-25 04:46:47 -0400 |
commit | 0b7b9748681845a76a23349c95edad62048b849b (patch) | |
tree | 88a7f4f5580ff691ee76b6305b6c42124592fd32 /pkg/network/network.go | |
parent | f51d18a10f30c0aa86fde4e1655b6aeb7b875b45 (diff) | |
parent | c3af2faab2dde219b286800a34552523a1d3f9e3 (diff) | |
download | podman-0b7b9748681845a76a23349c95edad62048b849b.tar.gz podman-0b7b9748681845a76a23349c95edad62048b849b.tar.bz2 podman-0b7b9748681845a76a23349c95edad62048b849b.zip |
Merge pull request #6238 from baude/v2compatnet
network compatibility endpoints for API
Diffstat (limited to 'pkg/network/network.go')
-rw-r--r-- | pkg/network/network.go | 18 |
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 +} |