This repository serves as a starting point for new Golang projects.
It includes a Makefile with common development targets with make,
a pre-configured development environment using Devbox,
GitHub Actions workflows, and release-please-action for release automation.
The template is configured with Kubebuilder v4 for building Kubernetes operators.
Kubebuilder manifests in config/ are automatically synced to the Helm chart using the kubebuilder.sync-chart make target,
which uses the Kubebuilder Helm plugin to keep your chart in sync with generated RBAC, manager, and other Kubernetes resources
...
Use this repo as the template for a new repository by making the following changes.
-
Add an initial version for release-please.
git commit --allow-empty -m "chore: release 0.0.1" -m "Release-As: 0.0.1" && git push origin main
-
Search and replace all instances of
golang-repository-templateandGolang Repository Templatewith your project's name. -
Search and replace all instances of
github.com/dkoshkinwith your Github username. -
Search and replace all instances of
com.dimitrikoshkinwith your company domain. -
Rename the folder in
cmd/andcharts/with your project's name. -
Update the files in
hack/licensewith your details. -
Clear out the release-please version.
echo "{}" > .release-please-manifest.json
This template is initialized with Kubebuilder to build Kubernetes controllers. To remove, make the following changes:
- Remove
kubebuilder.sync-charttarget inmake/goreleaser.mk. - Remove
generate manifeststarget frommake/go.mk. - Delete the
make/kubebuilder.mkand remove its reference frommake/all.mk. - Delete the
PROJECTfile. - Delete the
config/directory.
- Go to
Settings>Generaland enableAllow auto-mergeandAutomatically delete head branches. - Go to
Settings>General>Pull Requestsand unselectAllow merge commitsandAllow rebase merging. - Create a Github PATs to use in Github automation.
-
Another to use with Devbox update automation, adding the following permissions:
- Contents: read and write
- Pull Requests: read and write
- Issues: read and write
Go to
Settings>Secrets and variables>Actionsand add is asDEPENDENCY_AUTOMATION_TOKEN.Go to
Settings>Secrets and variables>Actionsand add these SecretsGIT_SSH_SIGNING_PRIVATE_KEY,GIT_USER_NAMEandGIT_USER_EMAIL.
-
- Go to
Settings>Branches>Add branch rulesetand configure it for the "default" andrelease/**/*branches. EnableRequire signed commitsandRequire a pull request before merging. EnableRequire status checks to passwith the following checks:- build / build
- lint / gha
- lint / go (.)
- lint / helm
- pre-commit / pre-commit
- unit-tests / unit-tests
- govulncheck / govulncheck (.)
- codeql / analyze (go)
- e2e-tests / e2e-tests
- Go to
Settings>Pages>Branchand selectmainand/docsas the Source.
This template is configured with Codecov that must be configured before using.
Go to Settings > Secrets and variables > Actions and add the generated token as CODECOV_TOKEN.
- Install Devbox
- Install direnv
- run
direnv allow
- run
- Install pre-commit git hooks
- run
pre-commit install
- run
Tip: to see all available make targets with descriptions, simply run make.
make testThis repository is configured with Codecov but can be removed by modifying .github/workflows/unit-tests.yml.
make build-snapshotThe binary for your OS will be placed in ./dist,
e.g. ./dist/golang-repository-template_darwin_arm64_v8.0/golang-repository-template:
make lint
make lint-chartmake pre-commitmake chart-docs
make schema-chartThe repository is configured with automation to periodically update dependencies.
- dependabot action to update both Github Actions and Golang
go.moddependencies using Dependabot. - devbox action to update Devbox packages.