summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/containers/containers.go12
-rw-r--r--pkg/bindings/containers/logs.go2
-rw-r--r--pkg/bindings/images/build.go2
-rw-r--r--pkg/bindings/network/network.go38
-rw-r--r--pkg/bindings/play/play.go6
-rw-r--r--pkg/bindings/test/images_test.go2
6 files changed, 57 insertions, 5 deletions
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go
index b5cd2128b..4331ae6c2 100644
--- a/pkg/bindings/containers/containers.go
+++ b/pkg/bindings/containers/containers.go
@@ -390,3 +390,15 @@ func ContainerInit(ctx context.Context, nameOrID string) error {
}
return response.Process(nil)
}
+
+func ShouldRestart(ctx context.Context, nameOrID string) (bool, error) {
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return false, err
+ }
+ response, err := conn.DoRequest(nil, http.MethodPost, "/containers/%s/shouldrestart", nil, nil, nameOrID)
+ if err != nil {
+ return false, err
+ }
+ return response.IsSuccess(), nil
+}
diff --git a/pkg/bindings/containers/logs.go b/pkg/bindings/containers/logs.go
index 750a6dbe1..a73517bac 100644
--- a/pkg/bindings/containers/logs.go
+++ b/pkg/bindings/containers/logs.go
@@ -1,7 +1,6 @@
package containers
import (
- "bytes"
"context"
"fmt"
"io"
@@ -64,7 +63,6 @@ func Logs(ctx context.Context, nameOrID string, opts LogOptions, stdoutChan, std
if err != nil {
return err
}
- frame = bytes.Replace(frame[0:l], []byte{13}, []byte{10}, -1)
switch fd {
case 0:
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 60ffea548..815ab4e86 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -187,7 +187,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
case s.Stream != "":
stdout.Write([]byte(s.Stream))
if re.Match([]byte(s.Stream)) {
- id = s.Stream
+ id = strings.TrimSuffix(s.Stream, "\n")
}
case s.Error != "":
return nil, errors.New(s.Error)
diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go
index 151d15d3e..1d4be8a4c 100644
--- a/pkg/bindings/network/network.go
+++ b/pkg/bindings/network/network.go
@@ -88,3 +88,41 @@ func List(ctx context.Context, options entities.NetworkListOptions) ([]*entities
}
return netList, response.Process(&netList)
}
+
+// Disconnect removes a container from a given network
+func Disconnect(ctx context.Context, networkName string, options entities.NetworkDisconnectOptions) error {
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return err
+ }
+ params := url.Values{}
+ body, err := jsoniter.MarshalToString(options)
+ if err != nil {
+ return err
+ }
+ stringReader := strings.NewReader(body)
+ response, err := conn.DoRequest(stringReader, http.MethodPost, "/networks/%s/disconnect", params, nil, networkName)
+ if err != nil {
+ return err
+ }
+ return response.Process(nil)
+}
+
+// Connect adds a container to a network
+func Connect(ctx context.Context, networkName string, options entities.NetworkConnectOptions) error {
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return err
+ }
+ params := url.Values{}
+ body, err := jsoniter.MarshalToString(options)
+ if err != nil {
+ return err
+ }
+ stringReader := strings.NewReader(body)
+ response, err := conn.DoRequest(stringReader, http.MethodPost, "/networks/%s/connect", params, nil, networkName)
+ if err != nil {
+ return err
+ }
+ return response.Process(nil)
+}
diff --git a/pkg/bindings/play/play.go b/pkg/bindings/play/play.go
index ffaee3208..cfb40d74b 100644
--- a/pkg/bindings/play/play.go
+++ b/pkg/bindings/play/play.go
@@ -28,8 +28,12 @@ func Kube(ctx context.Context, path string, options entities.PlayKubeOptions) (*
params := url.Values{}
params.Set("network", options.Network)
+ params.Set("logDriver", options.LogDriver)
if options.SkipTLSVerify != types.OptionalBoolUndefined {
- params.Set("tlsVerify", strconv.FormatBool(options.SkipTLSVerify == types.OptionalBoolTrue))
+ params.Set("tlsVerify", strconv.FormatBool(options.SkipTLSVerify != types.OptionalBoolTrue))
+ }
+ if options.Start != types.OptionalBoolUndefined {
+ params.Set("start", strconv.FormatBool(options.Start == types.OptionalBoolTrue))
}
// TODO: have a global system context we can pass around (1st argument)
diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go
index 681855293..7d9415f91 100644
--- a/pkg/bindings/test/images_test.go
+++ b/pkg/bindings/test/images_test.go
@@ -166,7 +166,7 @@ var _ = Describe("Podman images", func() {
// Adding one more image. There Should be no errors in the response.
// And the count should be three now.
- bt.Pull("busybox:glibc")
+ bt.Pull("testimage:20200929")
imageSummary, err = images.List(bt.conn, nil, nil)
Expect(err).To(BeNil())
Expect(len(imageSummary)).To(Equal(3))