-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix and simplify external plugin tests
- Loading branch information
1 parent
eae8b21
commit 083566d
Showing
8 changed files
with
110 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: External Plugin | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'pkg/' | ||
- 'docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin' | ||
- '.github/workflows/external-plugin.yml' | ||
pull_request: | ||
paths: | ||
- 'pkg/' | ||
- 'docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin' | ||
- '.github/workflows/external-plugin.yml' | ||
|
||
jobs: | ||
external: | ||
name: Verify external plugin | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
with: | ||
# Fetching minimal history to limit .git access | ||
fetch-depth: 1 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.3' | ||
|
||
- name: Build Sample External Plugin | ||
working-directory: docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1 | ||
run: | | ||
mkdir -p ./bin | ||
make build | ||
- name: Move Plugin Binary to Plugin Path | ||
run: | | ||
# Define the plugin destination for Linux (XDG_CONFIG_HOME path) | ||
XDG_CONFIG_HOME="${HOME}/.config" | ||
PLUGIN_DEST="$XDG_CONFIG_HOME/kubebuilder/plugins/sampleexternalplugin/v1" | ||
# Ensure destination exists and move the built binary | ||
mkdir -p "$PLUGIN_DEST" | ||
mv docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/bin/sampleexternalplugin "$PLUGIN_DEST/sampleexternalplugin" | ||
- name: Build Kubebuilder Binary | ||
run: | | ||
# Set kb_root_dir to avoid .git permissions issues | ||
export kb_root_dir=$(pwd) | ||
go build -o "${kb_root_dir}/bin/kubebuilder" ./cmd | ||
echo "${kb_root_dir}/bin" >> $GITHUB_PATH | ||
- name: Run Kubebuilder Commands | ||
env: | ||
KUBEBUILDER_ASSETS: $GITHUB_WORKSPACE/bin | ||
run: | | ||
# Ensure kubebuilder is executable | ||
which kubebuilder || exit 1 | ||
# Initialize a new project using the sample external plugin | ||
kubebuilder init --plugins sampleexternalplugin/v1 --domain sample.domain.com | ||
# Create an API using the plugin | ||
kubebuilder create api --plugins sampleexternalplugin/v1 --number=2 --group=example --version=v1alpha1 --kind=ExampleKind | ||
# Create a webhook using the plugin | ||
kubebuilder create webhook --plugins sampleexternalplugin/v1 --hooked --group=example --version=v1alpha1 --kind=ExampleKind | ||
- name: Verify Generated Files | ||
run: | | ||
# Check contents of the generated files | ||
grep "DOMAIN: sample.domain.com" ./initFile.txt || exit 1 | ||
grep "NUMBER: 2" ./apiFile.txt || exit 1 | ||
grep "HOOKED!" ./webhookFile.txt || exit 1 |
14 changes: 8 additions & 6 deletions
14
docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
module v1 | ||
|
||
go 1.22 | ||
go 1.22.0 | ||
|
||
toolchain go1.22.5 | ||
|
||
require ( | ||
github.com/spf13/pflag v1.0.5 | ||
sigs.k8s.io/kubebuilder/v4 v4.2.0 | ||
sigs.k8s.io/kubebuilder/v4 v4.3.0 | ||
) | ||
|
||
require ( | ||
github.com/gobuffalo/flect v1.0.2 // indirect | ||
github.com/gobuffalo/flect v1.0.3 // indirect | ||
github.com/spf13/afero v1.11.0 // indirect | ||
golang.org/x/mod v0.20.0 // indirect | ||
golang.org/x/mod v0.21.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
golang.org/x/tools v0.24.0 // indirect | ||
golang.org/x/text v0.19.0 // indirect | ||
golang.org/x/tools v0.26.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters