Skip to content

Commit bca81f3

Browse files
dd
1 parent 09e4b2d commit bca81f3

File tree

471 files changed

+3982
-14642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+3982
-14642
lines changed

.github/workflows/lint-sample.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
uses: golangci/golangci-lint-action@v6
3030
with:
3131
version: v1.59
32-
working-directory: testdata/project-v4-with-deploy-image
32+
working-directory: testdata/project-v4-with-plugins
3333
args: --config .golangci.yml ./...

.github/workflows/test-e2e-samples.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
- name: Create kind cluster
5555
run: kind create cluster
5656

57-
- name: Prepare project-v4-with-deploy-image
57+
- name: Prepare project-v4-with-plugins
5858
run: |
59-
KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/kustomization.yaml"
59+
KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-plugins/config/default/kustomization.yaml"
6060
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
6161
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
6262
# Uncomment only ValidatingWebhookConfiguration
@@ -68,12 +68,12 @@ jobs:
6868
# Comment the injection for MutatingWebhookConfiguration
6969
# Fixme: We should not scaffold or it should be commented
7070
# by default when only validation webhooks are scaffolded
71-
WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml"
71+
WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml"
7272
sed -i '3,11s/^/#/' $WEBHOOK_INJECTION_FILE_PATH
73-
cd testdata/project-v4-with-deploy-image/
73+
cd testdata/project-v4-with-plugins/
7474
go mod tidy
7575
76-
- name: Testing make test-e2e for project-v4-with-deploy-image
77-
working-directory: testdata/project-v4-with-deploy-image
76+
- name: Testing make test-e2e for project-v4-with-plugins
77+
working-directory: testdata/project-v4-with-plugins
7878
run: |
7979
make test-e2e

docs/book/src/plugins/deploy-image-plugin-v1-alpha.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ By using this plugin you will have:
1313
<aside class="note">
1414
<h1>Examples</h1>
1515

16-
See the "project-v4-with-deploy-image" directory under the [testdata][testdata] directory of the Kubebuilder project to check an example of a scaffolding created using this plugin.
16+
See the "project-v4-with-optional-plugins" directory under the [testdata][testdata] directory of the Kubebuilder project to check an example of a scaffolding created using this plugin.
1717

1818
</aside>
1919

docs/book/src/reference/envtest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Logs from the test runs are prefixed with `test-env`.
8383
8484
You can use the plugin [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) to check examples. This plugin allows users to scaffold API/Controllers to deploy and manage an Operand (image) on the cluster following the guidelines and best practices. It abstracts the complexities of achieving this goal while allowing users to customize the generated code.
8585
86-
Therefore, you can check that a test using ENV TEST will be generated for the controller which has the purpose to ensure that the Deployment is created successfully. You can see an example of its code implementation under the `testdata` directory with the [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) samples [here](https://github.com/kubernetes-sigs/kubebuilder/blob/v3.7.0/testdata/project-v4-with-deploy-image/controllers/busybox_controller_test.go).
86+
Therefore, you can check that a test using ENV TEST will be generated for the controller which has the purpose to ensure that the Deployment is created successfully. You can see an example of its code implementation under the `testdata` directory with the [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) samples [here](https://github.com/kubernetes-sigs/kubebuilder/blob/v3.7.0/testdata/project-v4-with-plugins/controllers/busybox_controller_test.go).
8787
8888
</aside>
8989

docs/book/src/reference/rescaffold.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ This way, you can easily overlay your project's code changes atop the new scaffo
4949
- Check out [video to show how it works](https://youtu.be/7997RIbx8kw?si=ODYMud5lLycz7osp)
5050
- See the [desing proposal documentation](../../../../designs/helper_to_upgrade_projects_by_rescaffolding.md)
5151

52-
[example]: ./../../../../testdata/project-v4-with-deploy-image/PROJECT
52+
[example]: ./../../../../testdata/project-v4-with-plugins/PROJECT
5353
[more-info]: ./../reference/project-config.md

test/testdata/generate.sh

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,22 @@ function scaffold_test_project {
3232
pushd $testdata_dir/$project
3333

3434
header_text "Generating project ${project} with flags: ${init_flags}"
35-
3635
go mod init sigs.k8s.io/kubebuilder/testdata/$project # our repo autodetection will traverse up to the kb module if we don't do this
37-
3836
header_text "Initializing project ..."
3937
$kb init $init_flags --domain testproject.org --license apache2 --owner "The Kubernetes authors"
4038

41-
if [ $project == "project-v4" ] || [ $project == "project-v4-config" ]; then
39+
if [ $project == "project-v4" ] ; then
4240
header_text 'Creating APIs ...'
4341
$kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false
4442
$kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false --force
4543
$kb create webhook --group crew --version v1 --kind Captain --defaulting --programmatic-validation
4644
$kb create api --group crew --version v1 --kind FirstMate --controller=true --resource=true --make=false
4745
$kb create webhook --group crew --version v1 --kind FirstMate --conversion
46+
$kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false
47+
$kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting
48+
fi
4849

49-
if [ $project == "project-v4" ]; then
50-
$kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false
51-
$kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting
52-
else
53-
$kb create api --group crew --version v1 --kind Admiral --controller=true --resource=true --namespaced=false --make=false
54-
$kb create webhook --group crew --version v1 --kind Admiral --defaulting
55-
fi
56-
elif [[ $project =~ multigroup ]]; then
50+
if [[ $project =~ multigroup ]]; then
5751
header_text 'Switching to multigroup layout ...'
5852
$kb edit --multigroup=true
5953

@@ -63,46 +57,30 @@ function scaffold_test_project {
6357

6458
$kb create api --group ship --version v1beta1 --kind Frigate --controller=true --resource=true --make=false
6559
$kb create webhook --group ship --version v1beta1 --kind Frigate --conversion
66-
6760
$kb create api --group ship --version v1 --kind Destroyer --controller=true --resource=true --namespaced=false --make=false
6861
$kb create webhook --group ship --version v1 --kind Destroyer --defaulting
69-
7062
$kb create api --group ship --version v2alpha1 --kind Cruiser --controller=true --resource=true --namespaced=false --make=false
7163
$kb create webhook --group ship --version v2alpha1 --kind Cruiser --programmatic-validation
7264

7365
$kb create api --group sea-creatures --version v1beta1 --kind Kraken --controller=true --resource=true --make=false
74-
7566
$kb create api --group sea-creatures --version v1beta2 --kind Leviathan --controller=true --resource=true --make=false
76-
7767
$kb create api --group foo.policy --version v1 --kind HealthCheckPolicy --controller=true --resource=true --make=false
78-
7968
$kb create api --group apps --version v1 --kind Deployment --controller=true --resource=false --make=false
80-
8169
$kb create api --group foo --version v1 --kind Bar --controller=true --resource=true --make=false
8270
$kb create api --group fiz --version v1 --kind Bar --controller=true --resource=true --make=false
83-
84-
if [ $project == "project-v4-multigroup" ] || [ $project == "project-v4-multigroup-with-deploy-image" ] ; then
85-
$kb create api --version v1 --kind Lakers --controller=true --resource=true --make=false
86-
$kb create webhook --version v1 --kind Lakers --defaulting --programmatic-validation
87-
fi
88-
elif [[ $project =~ deploy-image ]]; then
89-
header_text 'Creating Memcached API with deploy-image plugin ...'
90-
$kb create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:memcached:1.6.26-alpine3.19 --image-container-command="memcached,--memory-limit=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false
91-
$kb create api --group example.com --version v1alpha1 --kind Busybox --image=busybox:1.36.1 --plugins="deploy-image/v1-alpha" --make=false
92-
header_text 'Creating Memcached webhook ...'
93-
$kb create webhook --group example.com --version v1alpha1 --kind Memcached --programmatic-validation
9471
fi
9572

96-
if [[ $project == project-v4-with-grafana ]]; then
97-
header_text 'Editing project with Grafana plugin ...'
98-
$kb edit --plugins=grafana.kubebuilder.io/v1-alpha
99-
fi
100-
101-
make generate manifests
102-
if [[ $project =~ v4 ]]; then
103-
make build-installer
73+
if [[ $project =~ multigroup ]] || [[ $project =~ with-plugins ]] ; then
74+
header_text 'With Optional Plugins ...'
75+
header_text 'Creating APIs with deploy-image plugin ...'
76+
$kb create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:memcached:1.6.26-alpine3.19 --image-container-command="memcached,--memory-limit=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false
77+
$kb create api --group example.com --version v1alpha1 --kind Busybox --image=busybox:1.36.1 --plugins="deploy-image/v1-alpha" --make=false
78+
$kb create webhook --group example.com --version v1alpha1 --kind Memcached --programmatic-validation
79+
header_text 'Editing project with Grafana plugin ...'
80+
$kb edit --plugins=grafana.kubebuilder.io/v1-alpha
10481
fi
10582

83+
make build-installer
10684
rm -f go.sum
10785
go mod tidy
10886
popd
@@ -111,7 +89,5 @@ function scaffold_test_project {
11189
build_kb
11290

11391
scaffold_test_project project-v4 --plugins="go/v4"
114-
scaffold_test_project project-v4-multigroup --plugins="go/v4"
115-
scaffold_test_project project-v4-multigroup-with-deploy-image --plugins="go/v4"
116-
scaffold_test_project project-v4-with-deploy-image --plugins="go/v4"
117-
scaffold_test_project project-v4-with-grafana --plugins="go/v4"
92+
scaffold_test_project project-v4-multigroup-with-plugins --plugins="go/v4"
93+
scaffold_test_project project-v4-with-plugins --plugins="go/v4"

test/testdata/test.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ build_kb
3232

3333
# Project version v4-alpha
3434
test_project project-v4
35-
test_project project-v4-multigroup
36-
test_project project-v4-multigroup-with-deploy-image
37-
test_project project-v4-with-deploy-image
38-
test_project project-v4-with-grafana
35+
test_project project-v4-multigroup-with-plugins
36+
test_project project-v4-with-plugins

testdata/project-v4-multigroup-with-deploy-image/Makefile

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)