From be7bd9b6b2b5d04a97a96ae7b39224b3ec6c5123 Mon Sep 17 00:00:00 2001 From: Blair Drummond Date: Thu, 5 Aug 2021 20:54:43 -0400 Subject: [PATCH] Add private repo hack script --- hack/README.md | 1 + hack/install-private-repo.sh | 101 +++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100755 hack/install-private-repo.sh diff --git a/hack/README.md b/hack/README.md index 7547a0e028..40080b3a9c 100644 --- a/hack/README.md +++ b/hack/README.md @@ -15,6 +15,7 @@ This directory contains several scripts useful in the development process of Shi - `install-kubectl.sh` Install the kubectl command line. - `install-registry.sh` Install the local container registry in the KinD cluster. - `install-tekton.sh` Install the latest verified Tekton Pipeline release. +- `install-private-repo.sh` Install a "private repo" (sample-nodejs) as a ssh-gitserver inside kind. - `release.sh` Creates a new release of Shipwright Build. - `update-codegen.sh` Updates auto-generated client libraries. - `verify-codegen.sh` Verifies that auto-generated client libraries are up-to-date. diff --git a/hack/install-private-repo.sh b/hack/install-private-repo.sh new file mode 100755 index 0000000000..b1fdcc81dd --- /dev/null +++ b/hack/install-private-repo.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# Copyright The Shipwright Contributors +# +# SPDX-License-Identifier: Apache-2.0 + +# +# Installs a private git repo into the cluster (for testing private repo builds) +# + +set -eu + +DOCKER_PRIVATE_REPO_IMAGE=private-git-repo-test +KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" + +tmp_dir=$(mktemp -d -t ssh-XXXXXXXXXX) +trap "rm -rf $tmp_dir" EXIT + +ssh-keygen -b 2048 -t rsa -f $tmp_dir/sshkey -q -N "" + +echo "# Building a private repo docker image..." + +# The Dockerhub repo +# https://hub.docker.com/r/jkarlos/git-server-docker/ +cat < /git-server/keys/sshkey.pub \ + && chmod 600 /git-server/keys/sshkey.pub + +RUN git clone https://github.com/shipwright-io/sample-nodejs \ + /git-server/repos/sample-nodejs.git + +WORKDIR /git-server/ +EOF + +echo "# Loading into kind..." +kind load docker-image $DOCKER_PRIVATE_REPO_IMAGE --name $KIND_CLUSTER_NAME + +echo "# Deploying Git Server..." +cat < kubectl get secrets private-git-repo-test-secret -o json | jq -r '.data[]' | base64 -d > sshkey +# > chmod 600 sshkey +# > kubectl port-forward svc/gitserver 2222:22 +# > GIT_SSH_COMMAND='ssh -i sshkey -o IdentitiesOnly=yes -o StrictHostKeyChecking=no' \ +# git clone ssh://git@localhost:2222/git-server/repos/sample-private-repo.git +# +EOF