genworkato

package module
v0.0.0-...-eb95b08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 15 Imported by: 0

README

protoc-gen-workato

This is a Workato Connector generator for Google Protocol Buffers compiler protoc. The plugin generates a Connector file based on your publicly tagged methods.

Installation

go install github.com/SafetyCulture/protoc-gen-workato@latest

Usage

The plugin is invoked by passing the --workato_out, and --workato_opt options to the protoc compiler. The option has the following format:

--doc_opt=workato/config.yaml

Generation of the actions in workato relies on the usage of google.api.http and grpc.gateway.protoc_gen_openapiv2.options annotations.

A complete example can be found in proto/.

Development

This repo uses buf to build Protocol Buffers.

brew tap bufbuild/buf
brew install buf

To generate the image for fixtures run buf build -o fixtures/image.bin. To generate the annotations Go package run buf generate. Example buf generate s12/protobuf/workato/annotations.proto.

Testing

go test -v -run TestGenerateWorkatoConnector

After you are happy with the results, to update the snapshot run this command:

UPDATE_SNAPSHOTS=true go test -v -run TestGenerateWorkatoConnector

Documentation

Index

Constants

View Source
const VERSION = "1.0.0"

VERSION is the version of protoc-gen-workato being used.

Variables

SupportedFeatures describes a flag setting for supported features.

Functions

func GenerateWorkatoConnector

func GenerateWorkatoConnector(gendoctemplate *gendoc.Template, cfg *config.Config) ([]byte, error)

GenerateWorkatoConnector generates a Workato SDK Connector from protobufs

Types

type Plugin

type Plugin struct{}

Plugin describes a protoc code generate plugin. It's an implementation of Plugin from github.com/pseudomuto/protokit

func (*Plugin) Generate

Generate compiles the documentation and generates the CodeGeneratorResponse to send back to protoc. It does this by rendering a template based on the options parsed from the CodeGeneratorRequest.

type PluginOptions

type PluginOptions struct {
	ConfigFile string
}

PluginOptions encapsulates options for the plugin. The type of renderer, template file, and the name of the output file are included.

func ParseOptions

func ParseOptions(req *pluginpb.CodeGeneratorRequest) (*PluginOptions, error)

ParseOptions parses plugin options from a CodeGeneratorRequest. It does this by splitting the `Parameter` field from the request object and parsing out the type of renderer to use and the name of the file to be generated.

The parameter (`--workato_opt`) must be of the format <config_file_path>. The file will be written to the directory specified with the `--workato_out` argument to protoc.

Directories

Path Synopsis
cmd
protoc-gen-workato
protoc-gen-workato is used to generate supporting files for https://github.com/envoyproxy/workato.
protoc-gen-workato is used to generate supporting files for https://github.com/envoyproxy/workato.
extensions
s12

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL