Add new "bashbrew list" subcommand
This allows us to manipulate/use the repo lists from bashbrew directly in fun ways. For example, `bashbrew list --namespaces='_' --all | xargs -n1 docker pull`.
This commit is contained in:
parent
166a52934b
commit
f44eab6388
36
bashbrew.sh
36
bashbrew.sh
|
|
@ -9,7 +9,7 @@ dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
||||||
library="$dir/../library"
|
library="$dir/../library"
|
||||||
src="$dir/src"
|
src="$dir/src"
|
||||||
logs="$dir/logs"
|
logs="$dir/logs"
|
||||||
namespaces='library stackbrew'
|
namespaces='_ library stackbrew'
|
||||||
docker='docker'
|
docker='docker'
|
||||||
|
|
||||||
library="$(readlink -f "$library")"
|
library="$(readlink -f "$library")"
|
||||||
|
|
@ -21,9 +21,10 @@ self="$(basename "$0")"
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOUSAGE
|
cat <<EOUSAGE
|
||||||
|
|
||||||
usage: $self [build|push] [options] [repo[:tag] ...]
|
usage: $self [build|push|list] [options] [repo[:tag] ...]
|
||||||
ie: $self build --all
|
ie: $self build --all
|
||||||
$self push debian ubuntu:12.04
|
$self push debian ubuntu:12.04
|
||||||
|
$self list --namespaces='_' debian:7 hello-world
|
||||||
|
|
||||||
This script processes the specified Docker images using the corresponding
|
This script processes the specified Docker images using the corresponding
|
||||||
repository manifest files.
|
repository manifest files.
|
||||||
|
|
@ -38,8 +39,16 @@ common options:
|
||||||
--logs="$logs"
|
--logs="$logs"
|
||||||
Where to store the build logs
|
Where to store the build logs
|
||||||
--namespaces="$namespaces"
|
--namespaces="$namespaces"
|
||||||
Space separated list of namespaces to tag images in after
|
Space separated list of image namespaces to act upon
|
||||||
building
|
|
||||||
|
Note that "_" is a special case here for the unprefixed
|
||||||
|
namespace (ie, "debian" vs "library/debian"), and as such
|
||||||
|
will be implicitly ignored by the "push" subcommand
|
||||||
|
|
||||||
|
Also note that "build" will always tag to the unprefixed
|
||||||
|
namespace because it it necessary to do so for dependent
|
||||||
|
images to use FROM correctly (think "onbuild" variants that
|
||||||
|
are "FROM base-image:some-version")
|
||||||
|
|
||||||
build options:
|
build options:
|
||||||
--no-build Don't build, print what would build
|
--no-build Don't build, print what would build
|
||||||
|
|
@ -89,7 +98,7 @@ done
|
||||||
# which subcommand
|
# which subcommand
|
||||||
subcommand="$1"
|
subcommand="$1"
|
||||||
case "$subcommand" in
|
case "$subcommand" in
|
||||||
build|push)
|
build|push|list)
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
@ -324,6 +333,10 @@ while [ "$#" -gt 0 ]; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for namespace in $namespaces; do
|
for namespace in $namespaces; do
|
||||||
|
if [ "$namespace" = '_' ]; then
|
||||||
|
# images FROM other images is explicitly supported
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if ! (
|
if ! (
|
||||||
set -x
|
set -x
|
||||||
"$docker" tag -f "$repoTag" "$namespace/$repoTag"
|
"$docker" tag -f "$repoTag" "$namespace/$repoTag"
|
||||||
|
|
@ -335,8 +348,21 @@ while [ "$#" -gt 0 ]; do
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
list)
|
||||||
|
for namespace in $namespaces; do
|
||||||
|
if [ "$namespace" = '_' ]; then
|
||||||
|
echo "$repoTag"
|
||||||
|
else
|
||||||
|
echo "$namespace/$repoTag"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
push)
|
push)
|
||||||
for namespace in $namespaces; do
|
for namespace in $namespaces; do
|
||||||
|
if [ "$namespace" = '_' ]; then
|
||||||
|
# can't "docker push debian"; skip this namespace
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if [ "$doPush" ]; then
|
if [ "$doPush" ]; then
|
||||||
echo "Pushing $namespace/$repoTag..."
|
echo "Pushing $namespace/$repoTag..."
|
||||||
if ! "$docker" push "$namespace/$repoTag" &> "$thisLog" < /dev/null; then
|
if ! "$docker" push "$namespace/$repoTag" &> "$thisLog" < /dev/null; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue