diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal.go | 6 | ||||
-rw-r--r-- | libpod/image/image.go | 14 | ||||
-rw-r--r-- | libpod/oci.go | 14 |
3 files changed, 24 insertions, 10 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index f6c8781e0..1e49673bf 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -940,7 +940,7 @@ func (c *Container) makeBindMounts() error { return errors.Wrapf(err, "error creating resolv.conf for container %s", c.ID()) } if err = label.Relabel(newResolv, c.config.MountLabel, false); err != nil { - return errors.Wrapf(err, "error relabeling %q for container %q", newResolv, c.ID) + return errors.Wrapf(err, "error relabeling %q for container %q", newResolv, c.ID()) } c.state.BindMounts["/etc/resolv.conf"] = newResolv @@ -954,7 +954,7 @@ func (c *Container) makeBindMounts() error { return errors.Wrapf(err, "error creating hosts file for container %s", c.ID()) } if err = label.Relabel(newHosts, c.config.MountLabel, false); err != nil { - return errors.Wrapf(err, "error relabeling %q for container %q", newHosts, c.ID) + return errors.Wrapf(err, "error relabeling %q for container %q", newHosts, c.ID()) } c.state.BindMounts["/etc/hosts"] = newHosts @@ -966,7 +966,7 @@ func (c *Container) makeBindMounts() error { return errors.Wrapf(err, "error creating hostname file for container %s", c.ID()) } if err = label.Relabel(hostnamePath, c.config.MountLabel, false); err != nil { - return errors.Wrapf(err, "error relabeling %q for container %q", hostnamePath, c.ID) + return errors.Wrapf(err, "error relabeling %q for container %q", hostnamePath, c.ID()) } c.state.BindMounts["/etc/hostname"] = hostnamePath } diff --git a/libpod/image/image.go b/libpod/image/image.go index 197a83dc1..f39b1d78d 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -744,6 +744,20 @@ func (i *Image) Labels(ctx context.Context) (map[string]string, error) { return imgInspect.Labels, nil } +// GetLabel Returns a case-insensitive match of a given label +func (i *Image) GetLabel(ctx context.Context, label string) (string, error) { + imageLabels, err := i.Labels(ctx) + if err != nil { + return "", err + } + for k, v := range imageLabels { + if strings.ToLower(k) == strings.ToLower(label) { + return v, nil + } + } + return "", nil +} + // Annotations returns the annotations of an image func (i *Image) Annotations(ctx context.Context) (map[string]string, error) { manifest, manifestType, err := i.Manifest(ctx) diff --git a/libpod/oci.go b/libpod/oci.go index 61ae4b46e..e5db06540 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -535,7 +535,7 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error { // Sets time the container was started, but does not save it. func (r *OCIRuntime) startContainer(ctr *Container) error { // TODO: streams should probably *not* be our STDIN/OUT/ERR - redirect to buffers? - if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "start", ctr.ID()); err != nil { + if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "start", ctr.ID()); err != nil { return err } @@ -547,7 +547,7 @@ func (r *OCIRuntime) startContainer(ctr *Container) error { // killContainer sends the given signal to the given container func (r *OCIRuntime) killContainer(ctr *Container, signal uint) error { logrus.Debugf("Sending signal %d to container %s", signal, ctr.ID()) - if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "kill", ctr.ID(), fmt.Sprintf("%d", signal)); err != nil { + if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "kill", ctr.ID(), fmt.Sprintf("%d", signal)); err != nil { return errors.Wrapf(err, "error sending signal to container %s", ctr.ID()) } @@ -605,7 +605,7 @@ func (r *OCIRuntime) stopContainer(ctr *Container, timeout uint) error { args = []string{"kill", "--all", ctr.ID(), "KILL"} } - if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, args...); err != nil { + if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, args...); err != nil { // Again, check if the container is gone. If it is, exit cleanly. err := unix.Kill(ctr.state.PID, 0) if err == unix.ESRCH { @@ -631,12 +631,12 @@ func (r *OCIRuntime) deleteContainer(ctr *Container) error { // pauseContainer pauses the given container func (r *OCIRuntime) pauseContainer(ctr *Container) error { - return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "pause", ctr.ID()) + return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "pause", ctr.ID()) } // unpauseContainer unpauses the given container func (r *OCIRuntime) unpauseContainer(ctr *Container) error { - return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "resume", ctr.ID()) + return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "resume", ctr.ID()) } // execContainer executes a command in a running container @@ -740,7 +740,7 @@ func (r *OCIRuntime) execStopContainer(ctr *Container, timeout uint) error { // Stop using SIGTERM by default // Use SIGSTOP after a timeout logrus.Debugf("Killing all processes in container %s with SIGTERM", ctr.ID()) - if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "kill", "--all", ctr.ID(), "TERM"); err != nil { + if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "kill", "--all", ctr.ID(), "TERM"); err != nil { return errors.Wrapf(err, "error sending SIGTERM to container %s processes", ctr.ID()) } @@ -755,7 +755,7 @@ func (r *OCIRuntime) execStopContainer(ctr *Container, timeout uint) error { // Send SIGKILL logrus.Debugf("Killing all processes in container %s with SIGKILL", ctr.ID()) - if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "kill", "--all", ctr.ID(), "KILL"); err != nil { + if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, "kill", "--all", ctr.ID(), "KILL"); err != nil { return errors.Wrapf(err, "error sending SIGKILL to container %s processes", ctr.ID()) } |