Skip to content

Commit

Permalink
Automatically print kube context in dapper shell
Browse files Browse the repository at this point in the history
Use `kube-ps1` to print out the current context inside the dapper shell
(when running `make shell`).

This makes it easy to keep track of the current context and namespace,
and avoid confusion.

Signed-off-by: Mike Kolesnik <mkolesni@redhat.com>
  • Loading branch information
mkolesnik committed Nov 28, 2023
1 parent ffa8df0 commit 727a46d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package/Dockerfile.shipyard-dapper-base
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} PATH=/go/bin:/root/.l
# helm | e2e tests
# jq | JSON processing (GitHub API)
# kind | e2e tests
# kube-ps1 | print out kube context in dapper shell
# kubectl | e2e tests (in kubernetes-client)
# make | OLM installation
# moby-engine | Docker (for Dapper)
Expand Down Expand Up @@ -69,6 +70,7 @@ RUN LINT_VERSION=$(awk '/golangci-lint/ { print $2 }' /tools.mod) && \
BUILDX_VERSION=$(awk '/docker.buildx/ { print $2 }' /tools.mod) && \
curl -L "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-${ARCH}" -o /usr/local/libexec/docker/cli-plugins/docker-buildx && \
chmod 755 /usr/local/libexec/docker/cli-plugins/docker-buildx && \
curl -L https://raw.githubusercontent.com/jonmosco/kube-ps1/1b8fe913b25ba857b84a94c3b1dbf7bb34f7caef/kube-ps1.sh -o /etc/profile.d/kube-ps1.sh && \
find /go/bin /usr/local/libexec/docker/cli-plugins -type f -executable -newercc /proc -exec strip {} + && \
find /go/bin /usr/local/libexec/docker/cli-plugins -type f -executable -newercc /proc \( -execdir upx ${UPX_LEVEL} {} \; -o -true \) && \
go clean -cache -modcache && rm -f /tools.mod
Expand All @@ -79,6 +81,9 @@ RUN mkdir -p /root/.local/bin && ln -s $SCRIPTS_DIR/get-subctl.sh /root/.local/b
# Copy kubecfg to always run on the shell
COPY scripts/shared/lib/kubecfg /etc/profile.d/kubecfg.sh

# Print kube context on interactive shell
COPY scripts/shared/kubeps1.sh /etc/profile.d/

# Copy shared files so that downstream projects can use them
COPY Makefile.* .gitlint ${SHIPYARD_DIR}/

Expand Down
2 changes: 2 additions & 0 deletions scripts/shared/kubeps1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
PS1='[\u@\h \W $(kube_ps1)]\$ '

0 comments on commit 727a46d

Please sign in to comment.