plugin-registry-fs

File system installer for Plugin Registry

MIT License

Stars
0

File system installer for Plugin Registry

A file system installer for plugin-registry

Prerequisites

  • Go >= 1.16

Install

go get github.com/nhatthm/plugin-registry-fs

Usage

Import the library while bootstrapping the application (see the examples)

This installer supports installing:

  • A binary file
  • A folder
  • An archive (.tar.gz, .gz. or zip)

The source must be in this format:

./my-project/
├── .plugin.registry.yaml
└── my-plugin/
    └── (plugin files)

For example, if source is an archive, it should be:

./my-project/
├── .plugin.registry.yaml
└── my-plugin-1.0.0-darwin-amd64.tar.gz

Examples

package mypackage

import (
	"context"

	registry "github.com/nhatthm/plugin-registry"
	_ "github.com/nhatthm/plugin-registry-fs" // Add file system installer.
)

var defaultRegistry = mustCreateRegistry()

func mustCreateRegistry() registry.Registry {
	r, err := createRegistry()
	if err != nil {
		panic(err)
	}

	return r
}

func createRegistry() (registry.Registry, error) {
	return registry.NewRegistry("~/plugins")
}

func installPlugin(source string) error {
	return defaultRegistry.Install(context.Background(), source)
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

       or scan this