Skip to content

Latest commit

 

History

History
 
 

client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Longhorn API client

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.

Generate code in go-rancher

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.
cd $GOPATH/src/github.com/niusmallnan/
git clone https://github.com/niusmallnan/go-rancher
cd go-rancher
git checkout longhorn-v1
  1. Get dependencies.
GO111MODULE=off go get
  1. Generate code.
GO111MODULE=off scripts/generate-longhorn-schemas.sh http://<ip>:<port>

Copy code to longhorn-manager

  1. Copy the client to your project directory.
cp $GOPATH/src/github.com/niusmallnan/go-rancher/longhorn/*.go <project_directory>/client/
  1. Correct the package name.
cd <project_directory>/client
sed -i -e 's/package longhorn/package client/g' *.go
  1. 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.