You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+21-18
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,21 @@ We gratefully welcome improvements to documentation as well as to code.
8
8
9
9
## Getting Started
10
10
11
+
### Pre-requisites
12
+
13
+
*[Go](https://golang.org/doc/install).
14
+
* Docker version 23.0.0 or greater.
15
+
16
+
### Local development cheat sheet
17
+
18
+
*`make test` to run unit tests
19
+
*`make lint` to run linters
20
+
*`make fmt` to format Go code
21
+
*`make vet` to run `go vet`
22
+
*`make generate` to generate code and manifests based on Go struct definitions for CRDs.
23
+
24
+
`make precommit` includes all of the above.
25
+
11
26
### Workflow
12
27
13
28
It is recommended to follow the ["GitHub Workflow"](https://guides.github.com/introduction/flow/). When using [GitHub's CLI](https://github.com/cli/cli), here's how it typically looks like:
@@ -16,6 +31,7 @@ It is recommended to follow the ["GitHub Workflow"](https://guides.github.com/in
* Have a Kubernetes cluster ready for development. We recommend `minikube` or `kind`.
44
-
* Docker version 23.0.0 or greater.
45
-
46
55
### Adding new components - webhook, API
47
56
48
57
The repository structure MUST be compliant with `operator-sdk` scaffolding, which uses `kubebuilder` behind the scenes. This is to ensure a valid bundle generation and it makes it easy to maintain the project and add new components.
@@ -52,6 +61,7 @@ Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/
52
61
### Local run
53
62
54
63
Build the manifests, install the CRD and run the operator as a local process:
With an existing cluster (such as `minikube`), run:
102
-
```bash
103
-
USE_EXISTING_CLUSTER=true make test
104
-
```
105
-
106
-
Tests can also be run without an existing cluster. For that, install [`kubebuilder`](https://book.kubebuilder.io/quick-start.html#installation). In this case, the tests will bootstrap `etcd` and `kubernetes-api-server` for the tests. Run against an existing cluster whenever possible, though.
107
-
108
111
### Unit tests
109
112
110
113
Some unit tests use [envtest](https://book.kubebuilder.io/reference/envtest.html) which requires Kubernetes binaries (e.g. `api-server`, `etcd` and `kubectl`) to be present on the host filesystem. Makefile takes care of installing all dependent binaries, however running the tests from IDE or via `go test` might not work out-of-the-box. The `envtest` uses env variable `KUBEBUILDER_ASSETS` that points to a directory with these binaries. To make the test work in IDE or `go test` the environment variable has to be correctly set.
@@ -118,20 +121,20 @@ KUBEBUILDER_ASSETS=$(./bin/setup-envtest use -p path 1.23) go test ./pkg...
118
121
119
122
### End to end tests
120
123
121
-
To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`chainsaw`](https://kyverno.github.io/chainsaw). Refer to their documentation for installation instructions.
124
+
To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`chainsaw`](https://kyverno.github.io/chainsaw). They will be installed automatically in the project's local `bin/` directory.
122
125
123
-
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will set up a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.
126
+
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Keep in mind that you need to call `make prepare-e2e` again after you make changes to operator code or manifests.
124
127
125
128
The tests are located under `tests/e2e` and are written to be used with `chainsaw`. Refer to their documentation to understand how tests are written.
126
129
127
130
To revert the changes made by the `make prepare-e2e` run `make reset`.
128
131
129
132
### OpenShift End to End tests
130
-
To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster.
133
+
To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster.
131
134
132
135
To install the OpenTelemetry operator, please follow the instructions in [Operator Lifecycle Manager (OLM)](https://github.com/open-telemetry/opentelemetry-operator/blob/main/CONTRIBUTING.md#operator-lifecycle-manager-olm)
133
136
134
-
Once the operator is installed, the tests can be executed using `make e2e-openshift`, which will call to the `e2e-openshift` target. Note that `kind` is disabled for the TestSuite as the requirement is to use an OpenShift cluster for these test cases.
137
+
Once the operator is installed, the tests can be executed using `make e2e-openshift`, which will call to the `e2e-openshift` target. Note that `kind` is disabled for the TestSuite as the requirement is to use an OpenShift cluster for these test cases.
135
138
136
139
The tests are located under `tests/e2e-openshift` and are written to be used with `chainsaw`.
@git diff -s --exit-code docs/api.md || (echo "Build failed: the api.md file has been changed but the generated api.md file isn't up to date. Run 'make api-docs' and update your PR."&& git diff &&exit 1)
0 commit comments