Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
change 'stack build' to take an image parameter
Browse files Browse the repository at this point in the history
`kubectl crossplane stack build IMAGE $*` now passes '$*' to
'make build', not 'make'

Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Apr 3, 2020
1 parent be3aab7 commit 8656cbe
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions bin/kubectl-crossplane-stack-build
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/usr/bin/env bash

function usage {
echo "Usage: kubectl crossplane stack [-h|--help] build [ARGS ...]" >&2
echo "Usage: kubectl crossplane stack [-h|--help] build [STACK_IMAGE_NAME] [ARGS ...]" >&2
echo "" >&2
echo "ARGS: An alternate recipe to build, or other arguments to pass through" >&2
echo 'to `make`.' >&2
echo "" >&2
echo "STACK_IMAGE_NAME is the name that will be given to the built image." >&2
echo "Like any image name in the local docker registry, this may start">&2
echo "with a server address and end with a tag. If unspecified," >&2
echo "it will use whatever name the project was initialized with." >&2
echo "" >&2
echo 'ARGS are other arguments to pass through to `make build`.' >&2
echo "" >&2
echo "Examples:" >&2
echo "" >&2
echo "Build a stack and tag it with the default image name:" >&2
echo "kubectl crossplane stack build" >&2
echo "" >&2
echo "Build a stack and tag it for publishing to a local registry:" >&2
echo "kubectl crossplane stack build localhost:5000/mystackrepository/mystackimagename" >&2
echo "" >&2
echo "Build a stack and tag it for publishing to a public registry:" >&2
echo "kubectl crossplane stack build registry.upbound.io/username/repo-name:v0.0.1" >&2
echo "" >&2
echo "-h, --help: Print usage" >&2
}
Expand All @@ -18,11 +34,7 @@ function check_help {

check_help "${1}"

# We could also have just passed all the arguments through
# instead of extracting the command out, but it seems more
# clear what is happening in the no-argument case if the
# command is split out.
COMMAND=${1:-build}
STACK_IMG=${1}
shift

# Shift returns non-zero if there are no arguments left,
Expand All @@ -33,7 +45,7 @@ set -x
# If stack.Makefile exists, we want to use that. Otherwise,
# we'll use a regular Makefile.
if [[ -e stack.Makefile ]]; then
make -f stack.Makefile ${COMMAND} "$@"
make -f stack.Makefile build ${STACK_IMG:+"STACK_IMG=$STACK_IMG"} "$@"
else
make ${COMMAND} "$@"
make build ${STACK_IMG:+"STACK_IMG=$STACK_IMG"} "$@"
fi

0 comments on commit 8656cbe

Please sign in to comment.