Skip to content

Commit 06baaa4

Browse files
committed
update vendor for new test changes and vendoring
1 parent 4b072d8 commit 06baaa4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,42 @@ FeatureGateMyFeatureName = newFeatureGate("MyFeatureName").
5252
mustRegister()
5353
```
5454

55+
### defining tests
56+
Tests are logically associated with FeatureGates.
57+
When adding any FeatureGated functionality a new test file is required.
58+
The test files are located in `<group>/<version>/tests/<crd-name>/FeatureGate.yaml`:
59+
```
60+
route/
61+
v1/
62+
tests/
63+
routes.route.openshift.io/
64+
AAA_ungated.yaml
65+
ExternalRouteCertificate.yaml
66+
```
67+
Here's an `AAA_ungated.yaml` example:
68+
```yaml
69+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this.
70+
name: Route
71+
crdName: routes.route.openshift.io
72+
tests:
73+
```
74+
75+
Here's an `ExternalRouteCertificate.yaml` example:
76+
```yaml
77+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this.
78+
name: Route
79+
crdName: routes.route.openshift.io
80+
featureGate: ExternalRouteCertificate
81+
tests:
82+
```
83+
84+
The integration tests use the crdName and featureGate to determine which tests apply to which manifests and automatically
85+
react to changes when the FeatureGates are enabled/disabled on various FeatureSets and ClusterProfiles.
86+
87+
[`gen-minimal-test.sh`](tests/hack/gen-minimal-test.sh) can still function to stub out files if you don't want to
88+
copy/paste an existing one.
89+
90+
5591
## defining new APIs
5692

5793
When defining a new API, please follow [the OpenShift API
@@ -172,6 +208,18 @@ No, signing a team up to be a no-FF team includes some basic education on the pr
172208
participants are aware the team is moving to that model. If you'd like to sign your team up, please speak with Gina Hargan who will
173209
be happy to help on-board your team.
174210

211+
## vendoring generated manifests into other repositories
212+
If your repository relies on vendoring and copying CRD manifests (good job!), you'll need have an import line that
213+
depends on the package that contains the CRD manifests.
214+
For example, adding
215+
```go
216+
import (
217+
_ "github.com/openshift/api/operatoringress/v1/zz_generated.crd-manifests"
218+
)
219+
```
220+
to any .go file will work, but some commonly chosen files are `tools/tools.go` or `pkg/dependencymagnet/doc.go`.
221+
Once added, a `go mod vendor` will pick up the package containing the manifests for you to copy.
222+
175223
## generating CRD schemas
176224

177225
Since Kubernetes 1.16, every CRD created in `apiextensions.k8s.io/v1` is required to have a [structural OpenAPIV3 schema](https://kubernetes.io/blog/2019/06/20/crd-structural-schema/). The schemas provide server-side validation for fields, as well as providing the descriptions for `oc explain`. Moreover, schemas ensure structural consistency of data in etcd. Without it anything can be stored in a resource which can have security implications. As we host many of our CRDs in this repo along with their corresponding Go types we also require them to have schemas. However, the following instructions apply for CRDs that are not hosted here as well.

0 commit comments

Comments
 (0)