summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-01-18 18:52:06 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-01-19 15:18:03 +0100
commita45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d (patch)
treedfda1d8d5f64baa183dc0f166e2441d8719b1cc8 /pkg/domain
parent5b3c7a52939275784c45c9747dd5864bd0581ff5 (diff)
downloadpodman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.tar.gz
podman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.tar.bz2
podman-a45d22a1ddd2840cf8c3a38540aa8683cc0d5c7d.zip
podman network exists
Add podman network exists command with remote support. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/entities/engine_container.go1
-rw-r--r--pkg/domain/infra/abi/network.go15
-rw-r--r--pkg/domain/infra/tunnel/network.go11
3 files changed, 27 insertions, 0 deletions
diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go
index d2552770c..7b43ac961 100644
--- a/pkg/domain/entities/engine_container.go
+++ b/pkg/domain/entities/engine_container.go
@@ -60,6 +60,7 @@ type ContainerEngine interface {
NetworkConnect(ctx context.Context, networkname string, options NetworkConnectOptions) error
NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (*NetworkCreateReport, error)
NetworkDisconnect(ctx context.Context, networkname string, options NetworkDisconnectOptions) error
+ NetworkExists(ctx context.Context, networkname string) (*BoolReport, error)
NetworkInspect(ctx context.Context, namesOrIds []string, options InspectOptions) ([]NetworkInspectReport, []error, error)
NetworkList(ctx context.Context, options NetworkListOptions) ([]*NetworkListReport, error)
NetworkReload(ctx context.Context, names []string, options NetworkReloadOptions) ([]*NetworkReloadReport, error)
diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go
index e5ecf5c72..bc4328fcd 100644
--- a/pkg/domain/infra/abi/network.go
+++ b/pkg/domain/infra/abi/network.go
@@ -140,3 +140,18 @@ func (ic *ContainerEngine) NetworkDisconnect(ctx context.Context, networkname st
func (ic *ContainerEngine) NetworkConnect(ctx context.Context, networkname string, options entities.NetworkConnectOptions) error {
return ic.Libpod.ConnectContainerToNetwork(options.Container, networkname, options.Aliases)
}
+
+// NetworkExists checks if the given network exists
+func (ic *ContainerEngine) NetworkExists(ctx context.Context, networkname string) (*entities.BoolReport, error) {
+ config, err := ic.Libpod.GetConfig()
+ if err != nil {
+ return nil, err
+ }
+ exists, err := network.Exists(config, networkname)
+ if err != nil {
+ return nil, err
+ }
+ return &entities.BoolReport{
+ Value: exists,
+ }, nil
+}
diff --git a/pkg/domain/infra/tunnel/network.go b/pkg/domain/infra/tunnel/network.go
index d4e827580..bdb1beb03 100644
--- a/pkg/domain/infra/tunnel/network.go
+++ b/pkg/domain/infra/tunnel/network.go
@@ -78,3 +78,14 @@ func (ic *ContainerEngine) NetworkConnect(ctx context.Context, networkname strin
options := new(network.ConnectOptions).WithAliases(opts.Aliases)
return network.Connect(ic.ClientCtx, networkname, opts.Container, options)
}
+
+// NetworkExists checks if the given network exists
+func (ic *ContainerEngine) NetworkExists(ctx context.Context, networkname string) (*entities.BoolReport, error) {
+ exists, err := network.Exists(ic.ClientCtx, networkname, nil)
+ if err != nil {
+ return nil, err
+ }
+ return &entities.BoolReport{
+ Value: exists,
+ }, nil
+}