Skip to content

Commit 8a4f404

Browse files
committed
cmd-build-with-buildah: support registry auth
If we try to FROM: a container that's being auth for the container build then we'll need to provide some sort of pull secret. This change allows us to do that via `--authfile` or $REGISTRY_AUTH_FILE.
1 parent 8ffe5a3 commit 8a4f404

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cmd-build-with-buildah

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Usage: coreos-assembler build-with-buildah
2525
--parent-build=VERSION The version that represents the parent to this build. Used for RPM diffs
2626
that get added to the meta.json
2727
--force Import a new build even if inputhash has not changed.
28+
--authfile A registry pull secret to use when doing the build.
2829
EOF
2930
}
3031

@@ -37,7 +38,7 @@ SKIP_PRUNE=
3738
STRICT=
3839
PARENT_BUILD=
3940
rc=0
40-
options=$(getopt --options h,d --longoptions help,version:,versionary,direct,autolock:,skip-prune,parent-build:,force,strict -- "$@") || rc=$?
41+
options=$(getopt --options h,d --longoptions help,version:,versionary,direct,autolock:,skip-prune,parent-build:,force,strict,authfile: -- "$@") || rc=$?
4142
[ $rc -eq 0 ] || {
4243
print_help
4344
exit 1
@@ -76,6 +77,10 @@ while true; do
7677
--force)
7778
FORCE=1
7879
;;
80+
--authfile)
81+
shift
82+
REGISTRY_AUTH_FILE=$1
83+
;;
7984
--)
8085
shift
8186
break
@@ -216,6 +221,10 @@ build_with_buildah() {
216221
fi
217222
cat <<EOF > "${tempdir}/build-with-buildah-script.sh"
218223
set -euxo pipefail
224+
if [ -n "${REGISTRY_AUTH_FILE:-}" ]; then
225+
# Since we are changing dirs below let's make it an absolute path
226+
export REGISTRY_AUTH_FILE=\$(readlink -f "${REGISTRY_AUTH_FILE}")
227+
fi
219228
env -C ${tempdir}/src TMPDIR=$(realpath cache) buildah $@
220229
skopeo copy --quiet "${final_ref}" "${tmp_oci_archive}"
221230
EOF

0 commit comments

Comments
 (0)