|
| 1 | +# Contributing to the CodeFlare Operator |
| 2 | + |
| 3 | +Here are a few things to go over before getting started with CodeFlare Operator development: |
| 4 | + |
| 5 | +## Environment setup |
| 6 | + |
| 7 | +The following should be installed in your working environment: |
| 8 | +installation/) |
| 9 | + - Go 1.18.X |
| 10 | + - [Download release](https://go.dev/dl/) |
| 11 | + - [Install Instructions](https://go.dev/doc/install) |
| 12 | + - [Operator SDK](https://sdk.operatorframework.io/docs/installation/) |
| 13 | + - GCC |
| 14 | + |
| 15 | +## Basic Overview |
| 16 | +Under the `api` dir, the MCAD and InstaScale custom resources are defined: |
| 17 | + - See `mcad_types.go` and `instascale_types.go` |
| 18 | + |
| 19 | +Under `config/internal` are where the MCAD and InstaScale resource templates can be found: |
| 20 | + - Sorted under `mcad` and `insascale` subdirs |
| 21 | + |
| 22 | +The code for MCAD/InstaScale resource reconsilliation can be found in the `controllers` dir: |
| 23 | + - See `mcad_controller.go` and `instascale_controller.go` |
| 24 | + |
| 25 | +The main entrypoint for the operator is `main.go` |
| 26 | + |
| 27 | +## Building and Deployment |
| 28 | +If changes are made in the `api` dir, run: `make manifests` |
| 29 | + - This will generate new CRDs and associated files |
| 30 | + |
| 31 | +If changes are made to any Go code (like in the `controllers` dir for example), run: `make` |
| 32 | + - This will check and build/compile the modified code |
| 33 | + |
| 34 | +For building and pushing a new version of the operator image: |
| 35 | + - `make image-build -e IMG=<image-repo/image-name>` |
| 36 | + - `make image-push -e IMG<image-repo/image-name>` |
| 37 | + |
| 38 | +For deploying onto a cluster: |
| 39 | + - First, either set `KUBECONFIG` or ensure you are logged into a cluster in your environment |
| 40 | + - `make install` |
| 41 | + - `make deploy -e IMG=<image-repo/image-name>` |
| 42 | + |
| 43 | +## Testing |
| 44 | +The CodeFlare Operator currently has unit tests and pre-commit checks |
| 45 | + - To enable and view pre-commit checks: `pre-commit install` |
| 46 | + - To run unit tests, run `make test-unit` |
| 47 | + |
| 48 | +To write and inspect unit tests: |
| 49 | + - MCAD and InstaScale unit tests under `mcad_controller_test.go` and `instascale_controller_test.go` in the `controllers` dir |
| 50 | + - Unit test functions are defined in `suite_test.go` (with utils in `util/util.go`) in the `controllers dir` |
| 51 | + - Test cases defined under `controllers/testdata` |
0 commit comments