forked from longhorn/longhorn-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify the client generation process
- Loading branch information
Showing
1 changed file
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
# Longhorn API Client | ||
# Longhorn API client | ||
|
||
The code in this package are generated by [rancher/go-rancher](https://github.com/rancher/go-rancher). | ||
But in order to fix some compatibility issues, you need to use this [repo](https://github.com/niusmallnan/go-rancher), and you should checkout the `longhorn-v1` branch. | ||
The code in this package is generated by [rancher/go-rancher](https://github.com/rancher/go-rancher). But in order to | ||
fix some compatibility issues, you must use the `longhorn-v1` branch of this | ||
[repo](https://github.com/niusmallnan/go-rancher) instead. | ||
|
||
## Generate code in go-rancher | ||
|
||
If you have a longhorn api URL, you can use this script: | ||
The version of go-rancher we use does not have Go module support. It must be cloned onto the correct location on the | ||
GOPATH and the Go tools must be executed with `GO111MODULE=off`. This might be unusual for developers used to working | ||
with modern Go. | ||
|
||
1. Run longhorn-manager. There may be an easier way, but generally, this means deploy Longhorn to a cluster using a | ||
development version of the longhorn-manager container. | ||
2. Expose the longhorn-manager API. If running in a cluster, change the `spec.type` of the `longhorn-backend` service | ||
from `ClusterIP` to `NodePort`. The IP is the IP of any node and the port is given by `spec.ports.nodePort`. | ||
3. Clone go-rancher to the correct location on your GOPATH and check out the correct branch. | ||
|
||
```bash | ||
cd $GOPATH/src/github.com/niusmallnan/ | ||
git clone https://github.com/niusmallnan/go-rancher | ||
cd go-rancher | ||
``` | ||
./scripts/generate-longhorn-schemas.sh http://manager-api-ip:port | ||
|
||
4. Get dependencies. | ||
|
||
```bash | ||
``` | ||
|
||
5. Generate code. | ||
|
||
```bash | ||
GO111MODULE=off scripts/generate-longhorn-schemas.sh http://<ip>:<port> | ||
``` | ||
|
||
## Copy code to longhorn-manager | ||
|
||
Just use cp to copy these code is fine, but you should update package name in `longhorn-manager`: | ||
1. Copy the client to your project directory. | ||
|
||
```bash | ||
cp $GOPATH/src/github.com/niusmallnan/go-rancher/longhorn/*.go <project_directory>/client/ | ||
``` | ||
cd longhorn-manager/client | ||
|
||
2. Correct the package name. | ||
|
||
```bash | ||
cd <project_directory>/client | ||
sed -i -e 's/package longhorn/package client/g' *.go | ||
``` | ||
|
||
3. Check the `git diff`. There are likely unrelated changes you did not intend. For now, just revert any changes that | ||
don't appear to be directly related to your work. Maybe we can make the process more idempotent in the future. | ||
|
||
## Notes: | ||
|
||
The generator currently no longer generates actions, so you need to ensure not to overwrite the `ActionUpdateAccessMode` | ||
in `generated_volume.go`. I currently don't have the time to look into this and since we are planning on reworking the api | ||
down the line, this is a low priority issue for now. | ||
in `generated_volume.go`. I currently don't have the time to look into this and since we are planning on reworking the | ||
api down the line, this is a low priority issue for now. |