mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 10:00:11 +00:00
📖 add api/crd update doc (#913)
Some checks are pending
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Post / coverage (push) Waiting to run
Post / images (amd64) (push) Waiting to run
Post / images (arm64) (push) Waiting to run
Post / image manifest (push) Blocked by required conditions
Post / trigger clusteradm e2e (push) Blocked by required conditions
Some checks are pending
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Post / coverage (push) Waiting to run
Post / images (amd64) (push) Waiting to run
Post / images (arm64) (push) Waiting to run
Post / image manifest (push) Blocked by required conditions
Post / trigger clusteradm e2e (push) Blocked by required conditions
* add api/crd update doc Signed-off-by: Omar Farag <omarfarag74@gmail.com> * make requested changes Signed-off-by: Omar Farag <omarfarag74@gmail.com> * Use command instead of editing file Co-authored-by: Jian Zhu <jiazhu@redhat.com> Signed-off-by: Omar Farag <omarfarag74@gmail.com> --------- Signed-off-by: Omar Farag <omarfarag74@gmail.com> Co-authored-by: Jian Zhu <jiazhu@redhat.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Setting up dev environment](#setting-up-dev-environment)
|
||||
- [Building Images](#building-images)
|
||||
- [Making changes to the API and CRDs](#making-changes-to-the-api-and-crds)
|
||||
- [Testing the changes in the kind cluster](#testing-the-changes-in-the-kind-cluster)
|
||||
- [Integration tests](#integration-tests)
|
||||
- [E2E tests](#e2e-tests)
|
||||
@@ -143,6 +144,54 @@ After building the images, you can push them to the registry by docker/podman pu
|
||||
you can use the command `kind load docker-image quay.io/open-cluster-management/<image-name>:test` to load the
|
||||
images into the kind cluster.
|
||||
|
||||
### Making changes to the API and CRDs
|
||||
|
||||
In order to change Custom Resource Definitions and the API in [ocm](https://github.com/open-cluster-management-io/ocm), one needs to make changes to the [api](https://github.com/open-cluster-management-io/api) repository and then use them in the [ocm](https://github.com/open-cluster-management-io/ocm) repository. This section aims to walk you through these steps with an example.
|
||||
|
||||
|
||||
1. Clone a fork of both ocm and api to your machine
|
||||
```shell
|
||||
git clone git@github.com:<your-username>/api.git
|
||||
git clone git@github.com:<your-username>/ocm.git
|
||||
```
|
||||
|
||||
2. Make your API changes
|
||||
|
||||
Make your changes in your api repository. For example, let's say you wanted to change the `ClientCertExpirationSeconds` to be `ClientCertExpirationMinutes` for some reason:
|
||||
|
||||
|
||||
```go
|
||||
type RegistrationConfiguration struct {
|
||||
// clientCertExpirationMinutes represents the minutes of a client certificate to expire. If it is not set or 0, the default
|
||||
// duration minutes will be set by the hub cluster. If the value is larger than the max signing duration minutes set on
|
||||
// the hub cluster, the max signing duration minutes will be set.
|
||||
// +optional
|
||||
ClientCertExpirationMinutes int32 `json:"clientCertExpirationMinutes,omitempty"`
|
||||
...
|
||||
```
|
||||
In your api repository, run the following to generate CRDs and DeepCopy functions
|
||||
```shell
|
||||
user@fedora:~/api$ make update
|
||||
```
|
||||
|
||||
You'll notice that a few files such as `operator/v1/zz_generated.deepcopy.go` and `operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml` have been changed to reflect the changes in the API and CRD.
|
||||
3. Sync API updates with ocm repository
|
||||
|
||||
In order to use the new API, you'll have to sync them to your ocm repository. In your ocm repository, go to your go.mod file and replace `open-cluster-management.io/api` with your own updated version. This can be done by using the `replace` directive. At the end of the go.mod file, add:
|
||||
|
||||
```go
|
||||
go mod edit -replace open-cluster-management.io/api=/home/<user>/api #path to my local api repo w/ changes
|
||||
```
|
||||
|
||||
_Note: Only use the replace directive during development/debugging. Make sure to remove it before making a PR to [ocm](https://github.com/open-cluster-management-io/ocm) and once changes to the upstream [api repo](https://github.com/open-cluster-management-io/api) are merged._
|
||||
|
||||
Then, in your ocm repository, run the following:
|
||||
```shell
|
||||
user@fedora:~/ocm$ go mod tidy
|
||||
user@fedora:~/ocm$ go mod vendor
|
||||
user@fedora:~/ocm$ make update
|
||||
```
|
||||
|
||||
### Testing the changes in the kind cluster
|
||||
|
||||
After building and pushing the images, you can test the changes in the kind cluster.
|
||||
|
||||
Reference in New Issue
Block a user