github.com/vvnotw/moby@v1.13.1/pkg/plugins/pluginrpc-gen/README.md (about)

     1  Plugin RPC Generator
     2  ====================
     3  
     4  Generates go code from a Go interface definition for proxying between the plugin
     5  API and the subsystem being extended.
     6  
     7  ## Usage
     8  
     9  Given an interface definition:
    10  
    11  ```go
    12  type volumeDriver interface {
    13  	Create(name string, opts opts) (err error)
    14  	Remove(name string) (err error)
    15  	Path(name string) (mountpoint string, err error)
    16  	Mount(name string) (mountpoint string, err error)
    17  	Unmount(name string) (err error)
    18  }
    19  ```
    20  
    21  **Note**: All function options and return values must be named in the definition.
    22  
    23  Run the generator:
    24  
    25  ```bash
    26  $ pluginrpc-gen --type volumeDriver --name VolumeDriver -i volumes/drivers/extpoint.go -o volumes/drivers/proxy.go
    27  ```
    28  
    29  Where:
    30  - `--type` is the name of the interface to use
    31  - `--name` is the subsystem that the plugin "Implements"
    32  - `-i` is the input file containing the interface definition
    33  - `-o` is the output file where the the generated code should go
    34  
    35  **Note**: The generated code will use the same package name as the one defined in the input file
    36  
    37  Optionally, you can skip functions on the interface that should not be
    38  implemented in the generated proxy code by passing in the function name to `--skip`.
    39  This flag can be specified multiple times.
    40  
    41  You can also add build tags that should be prepended to the generated code by
    42  supplying `--tag`. This flag can be specified multiple times.
    43  
    44  ## Known issues
    45  
    46  ## go-generate
    47  
    48  You can also use this with go-generate, which is pretty awesome.  
    49  To do so, place the code at the top of the file which contains the interface
    50  definition (i.e., the input file):
    51  
    52  ```go
    53  //go:generate pluginrpc-gen -i $GOFILE -o proxy.go -type volumeDriver -name VolumeDriver
    54  ```
    55  
    56  Then cd to the package dir and run `go generate`
    57  
    58  **Note**: the `pluginrpc-gen` binary must be within your `$PATH`