The code in this package is generated by rancher/go-rancher. But in order to
fix some compatibility issues, you must use the longhorn-v1
branch of this
repo instead.
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.
- 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.
- Expose the longhorn-manager API. If running in a cluster, change the
spec.type
of thelonghorn-backend
service fromClusterIP
toNodePort
. The IP is the IP of any node and the port is given byspec.ports.nodePort
. - Clone go-rancher to the correct location on your GOPATH and check out the correct branch.
cd $GOPATH/src/github.com/niusmallnan/
git clone https://github.com/niusmallnan/go-rancher
cd go-rancher
git checkout longhorn-v1
- Get dependencies.
GO111MODULE=off go get
- Generate code.
GO111MODULE=off scripts/generate-longhorn-schemas.sh http://<ip>:<port>
- Copy the client to your project directory.
cp $GOPATH/src/github.com/niusmallnan/go-rancher/longhorn/*.go <project_directory>/client/
- Correct the package name.
cd <project_directory>/client
sed -i -e 's/package longhorn/package client/g' *.go
- 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.
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.