diff --git a/README.md b/README.md index a8d725cf..86f80ae1 100644 --- a/README.md +++ b/README.md @@ -303,13 +303,13 @@ The config provides information for composing a set of transformers: migrations = "to/db/migrations" ``` - `home` is the name of the package you are building the plugin for, in most cases this is github.com/vulcanize/vulcanizedb -our `$GOPATH` but setting this to `true` overrides that. This needs to be set to `true` for the configs used in tests in order for them to work with Travis. - `name` is the name used for the plugin files (.so and .go) - `save` indicates whether or not the user wants to save the .go file instead of removing it after .so compilation. Sometimes useful for debugging/trouble-shooting purposes. - `transformerNames` is the list of the names of the transformers we are composing together, so we know how to access their submaps in the exporter map - `exporter.`s are the sub-mappings containing config info for the transformers - `repository` is the path for the repository which contains the transformer and its `TransformerInitializer` - - `path` is the relative path from `repository` to the transformer's `TransformerInitializer` directory (initializer package) + - `path` is the relative path from `repository` to the transformer's `TransformerInitializer` directory (initializer package). + - Transformer repositories need to be cloned into the user's $GOPATH (`go get`) - `type` is the type of the transformer; indicating which type of watcher it works with (for now, there are only two options: `eth_event` and `eth_storage`) - `eth_storage` indicates the transformer works with the [storage watcher](https://github.com/vulcanize/maker-vulcanizedb/blob/compose_and_execute/libraries/shared/watcher/storage_watcher.go) that fetches state and storage diffs from an ETH node (instead of, for example, from IPFS) diff --git a/pkg/plugin/builder/builder.go b/pkg/plugin/builder/builder.go index 843b7eee..c16e50b1 100644 --- a/pkg/plugin/builder/builder.go +++ b/pkg/plugin/builder/builder.go @@ -60,15 +60,15 @@ func (b *builder) BuildPlugin() error { } // setup env to build plugin - err = b.setupBuildEnv() - if err != nil { - return err + setupErr := b.setupBuildEnv() + if setupErr != nil { + return setupErr } // Build the .go file into a .so plugin - err = exec.Command("go", "build", "-buildmode=plugin", "-o", soFile, b.goFile).Run() - if err != nil { - return errors.New(fmt.Sprintf("unable to build .so file: %s", err.Error())) + execErr := exec.Command("go", "build", "-buildmode=plugin", "-o", soFile, b.goFile).Run() + if execErr != nil { + return errors.New(fmt.Sprintf("unable to build .so file: %s", execErr.Error())) } return nil } @@ -87,20 +87,20 @@ func (b *builder) setupBuildEnv() error { // Import transformer dependencies so that we can build our plugin for importPath := range repoPaths { dst := filepath.Join(vendorPath, importPath) - src, err := helpers.CleanPath(filepath.Join("$GOPATH/src", importPath)) - if err != nil { - return err + src, cleanErr := helpers.CleanPath(filepath.Join("$GOPATH/src", importPath)) + if cleanErr != nil { + return cleanErr } - err = helpers.CopyDir(src, dst, "vendor") - if err != nil { - return errors.New(fmt.Sprintf("unable to copy transformer dependency from %s to %s: %v", src, dst, err)) + copyErr := helpers.CopyDir(src, dst, "vendor") + if copyErr != nil { + return errors.New(fmt.Sprintf("unable to copy transformer dependency from %s to %s: %v", src, dst, copyErr)) } // Have to clear out the copied over vendor lib or plugin won't build (see issue above) - err = os.RemoveAll(filepath.Join(dst, "vendor")) - if err != nil { - return err + removeErr := os.RemoveAll(filepath.Join(dst, "vendor")) + if removeErr != nil { + return removeErr } // Keep track of this vendor directory to clear later b.tmpVenDirs = append(b.tmpVenDirs, dst) diff --git a/pkg/plugin/helpers/helpers.go b/pkg/plugin/helpers/helpers.go index 4df98991..0455efdb 100644 --- a/pkg/plugin/helpers/helpers.go +++ b/pkg/plugin/helpers/helpers.go @@ -80,16 +80,19 @@ func CopyDir(src string, dst string, excludeRecursiveDir string) error { var fds []os.FileInfo var srcinfo os.FileInfo - if srcinfo, err = os.Stat(src); err != nil { + srcinfo, err = os.Stat(src) + if err != nil { return err } - if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil { - return err + mkErr := os.MkdirAll(dst, srcinfo.Mode()) + if mkErr != nil { + return mkErr } - if fds, err = ioutil.ReadDir(src); err != nil { - return err + fds, readErr := ioutil.ReadDir(src) + if err != readErr { + return readErr } for _, fd := range fds { srcfp := filepath.Join(src, fd.Name()) @@ -97,15 +100,15 @@ func CopyDir(src string, dst string, excludeRecursiveDir string) error { if fd.IsDir() { if fd.Name() != excludeRecursiveDir { - err = CopyDir(srcfp, dstfp, "") - if err != nil { - return err + dirErr := CopyDir(srcfp, dstfp, "") + if dirErr != nil { + return dirErr } } } else { - err = CopyFile(srcfp, dstfp) - if err != nil { - return err + fileErr := CopyFile(srcfp, dstfp) + if fileErr != nil { + return fileErr } } }