Skip to content

Commit

Permalink
dev: add support for podman
Browse files Browse the repository at this point in the history
Part of: DEVINF-522

Epic: none
Release note: None
  • Loading branch information
rickystewart committed Sep 19, 2023
1 parent 33623e3 commit c0c5de7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=86
DEV_VERSION=87

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
19 changes: 19 additions & 0 deletions pkg/cmd/dev/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package main

import (
"bytes"
"context"
"fmt"
"log"
Expand Down Expand Up @@ -56,6 +57,17 @@ func (d *dev) builder(cmd *cobra.Command, extraArgs []string) error {
return d.exec.CommandContextInheritingStdStreams(ctx, "docker", args...)
}

func (d *dev) dockerIsPodman(ctx context.Context) (bool, error) {
output, err := d.exec.CommandContextSilent(ctx, "docker", "help")
if err != nil {
return false, err
}
if bytes.Contains(output, []byte("podman")) {
return true, nil
}
return false, nil
}

func (d *dev) getDockerRunArgs(
ctx context.Context, volume string, tty bool, extraArgs []string,
) (args []string, err error) {
Expand Down Expand Up @@ -119,6 +131,13 @@ func (d *dev) getDockerRunArgs(
}

args = append(args, "run", "--rm")
isPodman, err := d.dockerIsPodman(ctx)
if err != nil {
return nil, err
}
if isPodman {
args = append(args, "--passwd=false")
}
if tty {
args = append(args, "-it")
} else {
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/dev/testdata/recorderdriven/builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ id
bazel info workspace --color=no
cat crdb-checkout/build/.bazelbuilderversion
docker volume inspect bzlhome
docker help
mkdir crdb-checkout/artifacts
docker run --rm -it -v crdb-checkout:/cockroach --workdir=/cockroach -v crdb-checkout/build/bazelutil/empty.bazelrc:/cockroach/.bazelrc.user -v crdb-checkout/artifacts:/artifacts -v bzlhome:/home/roach:delegated -u 502:502 cockroachdb/bazel:20220328-163955

Expand All @@ -15,5 +16,6 @@ id
bazel info workspace --color=no
cat crdb-checkout/build/.bazelbuilderversion
docker volume inspect bzlhome
docker help
mkdir crdb-checkout/artifacts
docker run --rm -i -v crdb-checkout:/cockroach --workdir=/cockroach -v crdb-checkout/build/bazelutil/empty.bazelrc:/cockroach/.bazelrc.user -v crdb-checkout/artifacts:/artifacts -v bzlhome:/home/roach:delegated -u 502:502 cockroachdb/bazel:20220328-163955 echo hi
6 changes: 6 additions & 0 deletions pkg/cmd/dev/testdata/recorderdriven/builder.rec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ docker volume inspect bzlhome
}
]

docker help
----

mkdir crdb-checkout/artifacts
----

Expand Down Expand Up @@ -62,6 +65,9 @@ docker volume inspect bzlhome
}
]

docker help
----

mkdir crdb-checkout/artifacts
----

Expand Down

0 comments on commit c0c5de7

Please sign in to comment.