summaryrefslogtreecommitdiff
path: root/pkg/bindings/network/network.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-12-08 15:31:49 +0100
committerPaul Holzinger <pholzing@redhat.com>2021-12-14 15:23:39 +0100
commit4791595b5cb3b2350c66b0d1ba91a6a171652409 (patch)
tree8b14ea4bdf587b2ace2debd49c51b76977b9bdd6 /pkg/bindings/network/network.go
parent9ce6b64133bc37433efac391bcaf9234c3890fc5 (diff)
downloadpodman-4791595b5cb3b2350c66b0d1ba91a6a171652409.tar.gz
podman-4791595b5cb3b2350c66b0d1ba91a6a171652409.tar.bz2
podman-4791595b5cb3b2350c66b0d1ba91a6a171652409.zip
network connect allow ip, ipv6 and mac address
Network connect now supports setting a static ipv4, ipv6 and mac address for the container network. The options are added to the cli and api. Fixes #9883 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/bindings/network/network.go')
-rw-r--r--pkg/bindings/network/network.go25
1 files changed, 8 insertions, 17 deletions
diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go
index 172598be1..66e01a016 100644
--- a/pkg/bindings/network/network.go
+++ b/pkg/bindings/network/network.go
@@ -3,7 +3,6 @@ package network
import (
"context"
"net/http"
- "net/url"
"strings"
"github.com/containers/podman/v3/libpod/network/types"
@@ -110,8 +109,6 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrID strin
if err != nil {
return err
}
- // No params are used for disconnect
- params := url.Values{}
// Disconnect sends everything in body
disconnect := struct {
Container string
@@ -128,7 +125,7 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrID strin
return err
}
stringReader := strings.NewReader(body)
- response, err := conn.DoRequest(ctx, stringReader, http.MethodPost, "/networks/%s/disconnect", params, nil, networkName)
+ response, err := conn.DoRequest(ctx, stringReader, http.MethodPost, "/networks/%s/disconnect", nil, nil, networkName)
if err != nil {
return err
}
@@ -138,32 +135,26 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrID strin
}
// Connect adds a container to a network
-func Connect(ctx context.Context, networkName string, ContainerNameOrID string, options *ConnectOptions) error {
+func Connect(ctx context.Context, networkName string, containerNameOrID string, options *types.PerNetworkOptions) error {
if options == nil {
- options = new(ConnectOptions)
+ options = new(types.PerNetworkOptions)
}
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
}
- // No params are used in connect
- params := url.Values{}
// Connect sends everything in body
- connect := struct {
- Container string
- Aliases []string
- }{
- Container: ContainerNameOrID,
- }
- if aliases := options.GetAliases(); options.Changed("Aliases") {
- connect.Aliases = aliases
+ connect := entities.NetworkConnectOptions{
+ Container: containerNameOrID,
+ PerNetworkOptions: *options,
}
+
body, err := jsoniter.MarshalToString(connect)
if err != nil {
return err
}
stringReader := strings.NewReader(body)
- response, err := conn.DoRequest(ctx, stringReader, http.MethodPost, "/networks/%s/connect", params, nil, networkName)
+ response, err := conn.DoRequest(ctx, stringReader, http.MethodPost, "/networks/%s/connect", nil, nil, networkName)
if err != nil {
return err
}