diff options
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r-- | pkg/domain/infra/abi/network.go | 15 | ||||
-rw-r--r-- | pkg/domain/infra/tunnel/network.go | 11 |
2 files changed, 26 insertions, 0 deletions
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 +} |