Development Environment
SchemaHero is written in Go and all of the source code is in a single repository.
To get started, we recommend:
- Install Go (1.16 or later)
- Fork and clone the SchemaHero repo
- Run
make
to generate all binaries andmake test
to execute the unite tests - Run
make -C integration run
to execute the integration tests
Testing
As you iterate on a change, there's a full set of integration tests that validate compatibility with all versions of all supported database engines. Running the integration tests will ensure that no local change is breaking support for the various supported databases. When adding a new feature, we encourage an integration test to be added also. SchemaHero is a complex project, and we depend on the tests to keep everything working properly.
Deployment
If you would like to E2E test your operator/cli changes, you can use this procedure to get it deployed:
- Start with a Kubernetes cluster context configured. If you need a cluster, try using K3D or KinD with docker/podman.
- You'll need ports exposed outside the cluster for the controller manager to connect to the database engine. You can either make sure NodePorts will be bound to the correct host machine now, or you can use
kubectl port-forward ...
later.
- You'll need ports exposed outside the cluster for the controller manager to connect to the database engine. You can either make sure NodePorts will be bound to the correct host machine now, or you can use
- Make sure you have
controller-gen
tools installed >=0.6.0. You can runmake controller-gen
to install, orcontroller-gen --version
to check your current version. NOTE: if you already have a version installed, you may need to manually upgrade:go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.0
- Deploy the Schemahero CRDs:
kubectl apply -f config/crds/v1
- Build the kubectl plugin:
make bin/kubectl-schemahero
You can run this outside of kubectl by directly calling the binary./bin/kubectl-schemahero
. - Build and run the controller manager:
make run
. - If necessary, deploy a test database engine using one of the convenience manifests located in
config/dev/database/
- If you plan on using a NodePort Service to connect your local controller manager to the DB, now would be the time to configure it.
- If you plan on using
kubectl port-forward ...
instead, run the appropriate command in a new terminal window.
- Create a database CR that uses the externally available connection url for your database in the cluster.
- Profit!