mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Allow passing extra build flags to Podman/Docker This is supported via 2 new env vars: - ODO_IMAGE_BUILD_ARGS: passed when building images via Podman/Docker - ODO_CONTAINER_RUN_ARGS: passed when running odo dev on Podman Those are comma-separated list of options that can be passed to either Podman or Docker (depending on the PODMAN_CMD env var). * Refactor 'build-images' tests to make it easier to add additional tests * Add integration tests for passing build extra args * Add integration tests for passing global extra args to Podman * Distinguish between global options passed to Podman and specific options for 'podman play kube' Previously, we were handling 'ODO_CONTAINER_RUN_ARGS' as global options for Podman, but this turns our not being that useful if we want to pass dedicated options to 'podman play kube'. This commit introduces a new 'ODO_CONTAINER_BACKEND_GLOBAL_ARGS' env var, which will be used as global options passed to every Podman command we execute. This paves the way to isolating our Podman-related tests further using the '--root' and '--runroot' global options. * Use `ODO_IMAGE_BUILD_ARGS` in the Advanced Guides * Use a semicolon as delimiter for extra flags Doing so because some of the options of Podman/Docker can actually be either repeated or comma-separated.
33 lines
928 B
Go
33 lines
928 B
Go
package podman
|
|
|
|
import (
|
|
"io"
|
|
"os/exec"
|
|
|
|
"k8s.io/klog"
|
|
)
|
|
|
|
// GetPodLogs returns the logs of the specified pod container.
|
|
// All logs for all containers part of the pod are returned if an empty string is provided as container name.
|
|
func (o *PodmanCli) GetPodLogs(podName, containerName string, followLog bool) (io.ReadCloser, error) {
|
|
args := []string{"pod", "logs"}
|
|
if followLog {
|
|
args = append(args, "--follow")
|
|
}
|
|
if containerName != "" {
|
|
args = append(args, "--container", podName+"-"+containerName)
|
|
}
|
|
args = append(args, podName)
|
|
|
|
cmd := exec.Command(o.podmanCmd, append(o.containerRunGlobalExtraArgs, args...)...)
|
|
klog.V(3).Infof("executing %v", cmd.Args)
|
|
|
|
out, _ := cmd.StdoutPipe()
|
|
// We get the commbined output as podman logs outputs logs in stdout && stderr (when kubectl outputs all logs on stdout)
|
|
cmd.Stderr = cmd.Stdout
|
|
if err := cmd.Start(); err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|