Skip to content

Commit 926dd60

Browse files
committed
ci: add a script to install sample external plugin
1 parent 597d2d6 commit 926dd60

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

test/e2e/ci.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
source "$(dirname "$0")/../common.sh"
1818
source "$(dirname "$0")/setup.sh"
1919

20+
build_sample_external_plugin
21+
2022
export KIND_CLUSTER="kind"
2123
create_cluster ${KIND_K8S_VERSION}
2224
trap delete_cluster EXIT

test/e2e/externalplugin/e2e_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ import (
2828
func TestE2E(t *testing.T) {
2929
RegisterFailHandler(Fail)
3030
fmt.Fprintf(GinkgoWriter, "Starting sample external plugin kubebuilder suite\n")
31-
RunSpecs(t, "Kubebuilder grafana plugin e2e suite")
31+
RunSpecs(t, "Kubebuilder sample external plugin e2e suite")
3232
}

test/e2e/local.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
source "$(dirname "$0")/../common.sh"
1818
source "$(dirname "$0")/setup.sh"
1919

20+
build_sample_external_plugin
21+
2022
export KIND_CLUSTER="local-kubebuilder-e2e"
2123
create_cluster ${KIND_K8S_VERSION}
2224
if [ -z "${SKIP_KIND_CLEANUP:-}" ]; then

test/e2e/setup.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,33 @@ function test_cluster {
6767
go test $(dirname "$0")/v4 $flags -timeout 30m
6868
go test $(dirname "$0")/externalplugin $flags -timeout 30m
6969
}
70+
71+
function build_sample_external_plugin {
72+
# TODO: Dynamically set exteranl plugin destination based on OS platform
73+
# EXTERNAL_PLUGIN_DESTINATION_PREFIX="${HOME}/Library/Application Support/kubebuilder/plugins"
74+
# For Linux:
75+
XDG_CONFIG_HOME="${HOME}/.config"
76+
EXTERNAL_PLUGIN_DESTINATION_PREFIX="$XDG_CONFIG_HOME/kubebuilder/plugins"
77+
78+
PLUGIN_NAME="sampleexternalplugin"
79+
PLUGIN_VERSION="v1"
80+
EXTERNAL_PLUGIN_DESTINATION="${EXTERNAL_PLUGIN_DESTINATION_PREFIX}/${PLUGIN_NAME}/${PLUGIN_VERSION}"
81+
EXTERNAL_PLUGIN_PATH="${EXTERNAL_PLUGIN_DESTINATION}/${PLUGIN_NAME}"
82+
83+
if [ -d "$EXTERNAL_PLUGIN_DESTINATION" ]; then
84+
echo "$EXTERNAL_PLUGIN_DESTINATION does exist."
85+
if [ -e "$EXTERNAL_PLUGIN_PATH" ]; then
86+
echo "clean up old binary..."
87+
rm "$EXTERNAL_PLUGIN_PATH"
88+
fi
89+
else
90+
mkdir -p "$EXTERNAL_PLUGIN_DESTINATION"
91+
fi
92+
93+
REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
94+
SOURCE_DIR="${REPO_ROOT_DIR}/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1"
95+
96+
cd $SOURCE_DIR && go build -o $PLUGIN_NAME && mv $PLUGIN_NAME "$EXTERNAL_PLUGIN_PATH"
97+
98+
cd $REPO_ROOT_DIR
99+
}

0 commit comments

Comments
 (0)