forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devcontainer): ✨ Devcontainer configuration file for
kubebuilder Add Go templates for scaffolding DevContainer related configuration files in a new Kubebuilder project. refactor(dev-container): Add separate post-create.sh script. refactor(dev-container): Use separate shell post create shell script in the container. fix(dev-container): Remove redudant /bin/bash field. :seedling: Bump github.com/onsi/ginkgo/v2 from 2.19.0 to 2.19.1 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.19.0 to 2.19.1. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.19.0...v2.19.1) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> :seedling: Bump github.com/onsi/gomega from 1.33.1 to 1.34.1 Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.33.1 to 1.34.1. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](onsi/gomega@v1.33.1...v1.34.1) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> fix: typo in designs template Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com> refactor(.devcontainer/Dockerfile): Use Go to install Kind binary. fix(.devcontainer): 🐛 Paas host network & update post-install script path. Use Host network to connect with the Host OS's Docker network. Also, execute the post-install.sh script from .devcontainer sub-directory, not the root. refactor(.devcontainer): Change go's version to 1.22.0. refactor(.devcontainer/Dockefile): Download Kubebuilder binary directly. refactor(.devcontainer/post-install.sh) Remove Makefile command. refactor(.devcontainer): Add check for verifying the existing Kind cluster. refactor(.devcontainer): Remove debug flag from post-install.sh fix(.devcontainer): Change interpreter from sh to bash in post-install.sh. refactor(templates): Add template for generating .devcontainer settings.⚠️ (cleanup/fix): ImplementWebhooks method should only be used by the e2e tests and should be under its package (kubernetes-sigs#4065) (cleanup/fix): ImplementWebhooks method should only be used by the e2e tests and should be under its package (cleanup): cleanup tests for plugin/util functions pkg/plugin/utils: add tests to cover funcs 🐛 (go/v4): add missing cancel context to controller's suite-test (kubernetes-sigs#4067) fix: add missing cancel context to controller's suite-test Upgrade the muilt-version sample to the latest :seedling: Bump github.com/onsi/ginkgo/v2 from 2.19.1 to 2.20.0 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.19.1 to 2.20.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.19.1...v2.20.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> 📖 docs:samples:cronjob: change makefile to generate the CRD without description to allow apply CRDs (kubernetes-sigs#4075) docs:samples:cronjob: fix makefile to generate the CRD with less description 🌱 Cleanup hack generate docs by removing code duplication (kubernetes-sigs#4076) (cleanup) hack docs fix(devcontainer.go): Resolve golangci-lint related issues. fix(devcontainer.go): Use bash command instead of '.' due to permission issuses. chore: Remove testDev Container files. docs(devcontainer): Generate documentation. test(devcontainer): Add a GH Action for testing dev-container build. test(devcontainer): Downgrade GH Runner to 20.04 Ubuntu. refactor(templates): Remove commented settings, and fix licencse year. ci(devcontainer): Remove commented code. sparkles: Add support to k8s 1.31 and upgrade dependencies (kubernetes-sigs#4080) Add support to k8s 1.31 Upgrade controller-gen used to generate the docs from 0.15.0 to 0.16.1 docs: improve and make clear info about setup envtest and its binaries ✨ upgrade kustomize from v5.4.2 to v5.4.3 (kubernetes-sigs#4084) upgrade kustomize from v5.4.2 to v5.4.3 refactor(devcontainer): Remove Dockerfile template. docs(devcontainer): Update test data files. ci(devcontainer): Run CI workflow on everpy PR, and push. chore: Fix linting typo. docs(devcontainer): Update test data files. ci(devcontainer): Run CI workflow on everpy PR, and push. chore: Fix linting typo. fix(devcontainer): Add license details in post-install.sh. ci(devcontainer): Update runner image. docs(devcontainer): Regenerate docs with license details.
- Loading branch information
Showing
17 changed files
with
582 additions
and
0 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,42 @@ | ||
name: Test DevContainer Image | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test-devcontainer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Go 1.22.x | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22.x" | ||
|
||
# required for installing devcontainer CLI | ||
- name: Setup NodeJS 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
|
||
- name: Setup Devcontainer CLI | ||
run: | | ||
npm install -g @devcontainers/cli | ||
- name: Build and Validate DevContainer | ||
run: | | ||
cd testdata/project-v4 | ||
OUTPUT=$(devcontainer up --workspace-folder=./) | ||
STATUS=$(echo "$OUTPUT" | jq -r '.outcome') | ||
if [[ "$STATUS" == "success" ]]; then | ||
echo "Devcontainer setup was successful." | ||
exit 0 | ||
else | ||
echo "Devcontainer setup failed." | ||
exit 1 | ||
fi |
26 changes: 26 additions & 0 deletions
26
docs/book/src/cronjob-tutorial/testdata/project/.devcontainer/devcontainer.json
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,26 @@ | ||
{ | ||
"name": "Kubebuilder DevContainer", | ||
"image": "golang:1.22-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
|
||
// Required for running Kind inside DevContainer | ||
"runArgs": ["--network=host"], | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
|
||
"onCreateCommand": "bash .devcontainer/post-install.sh" | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
docs/book/src/cronjob-tutorial/testdata/project/.devcontainer/post-install.sh
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,34 @@ | ||
#!/bin/bash | ||
# Copyright 2024 The Kubernetes Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 | ||
chmod +x ./kind | ||
mv ./kind /usr/local/bin/kind | ||
|
||
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 | ||
chmod +x kubebuilder | ||
mv kubebuilder /usr/local/bin/ | ||
|
||
curl -L -o kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin/kubectl | ||
|
||
kind version | ||
kubebuilder version | ||
docker --version | ||
go version | ||
kubectl version --client |
26 changes: 26 additions & 0 deletions
26
docs/book/src/getting-started/testdata/project/.devcontainer/devcontainer.json
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,26 @@ | ||
{ | ||
"name": "Kubebuilder DevContainer", | ||
"image": "golang:1.22-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
|
||
// Required for running Kind inside DevContainer | ||
"runArgs": ["--network=host"], | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
|
||
"onCreateCommand": "bash .devcontainer/post-install.sh" | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
docs/book/src/getting-started/testdata/project/.devcontainer/post-install.sh
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,34 @@ | ||
#!/bin/bash | ||
# Copyright 2024 The Kubernetes Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 | ||
chmod +x ./kind | ||
mv ./kind /usr/local/bin/kind | ||
|
||
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 | ||
chmod +x kubebuilder | ||
mv kubebuilder /usr/local/bin/ | ||
|
||
curl -L -o kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin/kubectl | ||
|
||
kind version | ||
kubebuilder version | ||
docker --version | ||
go version | ||
kubectl version --client |
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
118 changes: 118 additions & 0 deletions
118
pkg/plugins/golang/v4/scaffolds/internal/templates/devcontainer.go
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,118 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package templates | ||
|
||
import ( | ||
"sigs.k8s.io/kubebuilder/v4/pkg/machinery" | ||
) | ||
|
||
const devContainerTemplate = `{ | ||
"name": "Kubebuilder DevContainer", | ||
"image": "golang:1.22-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
// Required for running Kind inside DevContainer | ||
"runArgs": ["--network=host"], | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
"onCreateCommand": "bash .devcontainer/post-install.sh" | ||
} | ||
` | ||
|
||
const postInstallScript = `#!/bin/bash | ||
# Copyright 2024 The Kubernetes Authors. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
set -x | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 | ||
chmod +x ./kind | ||
mv ./kind /usr/local/bin/kind | ||
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 | ||
chmod +x kubebuilder | ||
mv kubebuilder /usr/local/bin/ | ||
curl -L -o kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin/kubectl | ||
kind version | ||
kubebuilder version | ||
docker --version | ||
go version | ||
kubectl version --client | ||
` | ||
|
||
var _ machinery.Template = &DevContainer{} | ||
var _ machinery.Template = &DevContainerPostInstallScript{} | ||
|
||
// DevCotaniner scaffoldds a `devcontainer.json` configurations file for | ||
// creating Kubebuilder & Kind based DevContainer. | ||
type DevContainer struct { | ||
machinery.TemplateMixin | ||
} | ||
|
||
type DevContainerPostInstallScript struct { | ||
machinery.TemplateMixin | ||
} | ||
|
||
func (f *DevContainer) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = ".devcontainer/devcontainer.json" | ||
} | ||
|
||
f.TemplateBody = devContainerTemplate | ||
|
||
return nil | ||
} | ||
|
||
func (f *DevContainerPostInstallScript) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = ".devcontainer/post-install.sh" | ||
} | ||
|
||
f.TemplateBody = postInstallScript | ||
|
||
return nil | ||
} |
26 changes: 26 additions & 0 deletions
26
testdata/project-v4-multigroup-with-deploy-image/.devcontainer/devcontainer.json
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,26 @@ | ||
{ | ||
"name": "Kubebuilder DevContainer", | ||
"image": "golang:1.22-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
|
||
// Required for running Kind inside DevContainer | ||
"runArgs": ["--network=host"], | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
|
||
"onCreateCommand": "bash .devcontainer/post-install.sh" | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
testdata/project-v4-multigroup-with-deploy-image/.devcontainer/post-install.sh
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,34 @@ | ||
#!/bin/bash | ||
# Copyright 2024 The Kubernetes Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 | ||
chmod +x ./kind | ||
mv ./kind /usr/local/bin/kind | ||
|
||
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 | ||
chmod +x kubebuilder | ||
mv kubebuilder /usr/local/bin/ | ||
|
||
curl -L -o kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin/kubectl | ||
|
||
kind version | ||
kubebuilder version | ||
docker --version | ||
go version | ||
kubectl version --client |
26 changes: 26 additions & 0 deletions
26
testdata/project-v4-multigroup/.devcontainer/devcontainer.json
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,26 @@ | ||
{ | ||
"name": "Kubebuilder DevContainer", | ||
"image": "golang:1.22-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/git:1": {} | ||
}, | ||
|
||
// Required for running Kind inside DevContainer | ||
"runArgs": ["--network=host"], | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
|
||
"onCreateCommand": "bash .devcontainer/post-install.sh" | ||
} | ||
|
Oops, something went wrong.