Categorygithub.com/nhatthm/plugin-registry-fs
modulepackage
0.3.0
Repository: https://github.com/nhatthm/plugin-registry-fs.git
Documentation: pkg.go.dev

# README

File system installer for Plugin Registry

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

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

paypal

       or scan this

# Functions

NewFsInstaller creates a new filesystem installer.
NewGzipInstaller creates a new filesystem installer.
NewZipInstaller creates a new filesystem installer.

# Variables

ErrIllegalFilePath indicates that the file path is illegal.
ErrPluginIsDir indicates that the plugin is a directory.
ErrPluginNotDir indicates that the plugin is not a directory.
ErrPluginNotGzip indicates that the plugin is not a zip.
ErrPluginNotZip indicates that the plugin is not a zip.

# Structs

ArchiveInstaller is an installer for archive file.
Installer is a file system installer.