Skip to content

Commit

Permalink
ci: add a script to install sample external plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Eileen-Yu committed May 30, 2023
1 parent 597d2d6 commit 78b7b50
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/e2e/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
source "$(dirname "$0")/../common.sh"
source "$(dirname "$0")/setup.sh"

build_sample_external_plugin

export KIND_CLUSTER="kind"
create_cluster ${KIND_K8S_VERSION}
trap delete_cluster EXIT
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/externalplugin/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ import (
func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
fmt.Fprintf(GinkgoWriter, "Starting sample external plugin kubebuilder suite\n")
RunSpecs(t, "Kubebuilder grafana plugin e2e suite")
RunSpecs(t, "Kubebuilder sample external plugin e2e suite")
}
2 changes: 2 additions & 0 deletions test/e2e/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
source "$(dirname "$0")/../common.sh"
source "$(dirname "$0")/setup.sh"

build_sample_external_plugin

export KIND_CLUSTER="local-kubebuilder-e2e"
create_cluster ${KIND_K8S_VERSION}
if [ -z "${SKIP_KIND_CLEANUP:-}" ]; then
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,30 @@ function test_cluster {
go test $(dirname "$0")/v4 $flags -timeout 30m
go test $(dirname "$0")/externalplugin $flags -timeout 30m
}

function build_sample_external_plugin {
# TODO: Dynamically set exteranl plugin destination based on OS platform
EXTERNAL_PLUGIN_DESTINATION_PREFIX="${HOME}/Library/Application Support/kubebuilder/plugins"

PLUGIN_NAME="sampleexternalplugin"
PLUGIN_VERSION="v1"
EXTERNAL_PLUGIN_DESTINATION="${EXTERNAL_PLUGIN_DESTINATION_PREFIX}/${PLUGIN_NAME}/${PLUGIN_VERSION}"
EXTERNAL_PLUGIN_PATH="${EXTERNAL_PLUGIN_DESTINATION}/${PLUGIN_NAME}"

if [ -d "$EXTERNAL_PLUGIN_DESTINATION" ]; then
echo "$EXTERNAL_PLUGIN_DESTINATION does exist."
if [ -e "$EXTERNAL_PLUGIN_PATH" ]; then
echo "clean up old binary..."
rm "$EXTERNAL_PLUGIN_PATH"
fi
else
mkdir -p "$EXTERNAL_PLUGIN_DESTINATION"
fi

REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
SOURCE_DIR="${REPO_ROOT_DIR}/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1"

cd $SOURCE_DIR && go build -o $PLUGIN_NAME && mv $PLUGIN_NAME "$EXTERNAL_PLUGIN_PATH"

cd $REPO_ROOT_DIR
}

0 comments on commit 78b7b50

Please sign in to comment.