fs

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 16 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Documentation

Overview

Package fs provides file system installers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPluginNotDir indicates that the plugin is not a directory.
	ErrPluginNotDir = errors.New("plugin is not a directory")
	// ErrPluginIsDir indicates that the plugin is a directory.
	ErrPluginIsDir = errors.New("plugin is a directory")
	// ErrIllegalFilePath indicates that the file path is illegal.
	ErrIllegalFilePath = errors.New("illegal file path")
)
View Source
var ErrPluginNotGzip = errors.New("plugin is not a gzip")

ErrPluginNotGzip indicates that the plugin is not a zip.

View Source
var ErrPluginNotZip = errors.New("plugin is not a zip")

ErrPluginNotZip indicates that the plugin is not a zip.

Functions

This section is empty.

Types

type ArchiveInstaller

type ArchiveInstaller struct {
	// contains filtered or unexported fields
}

ArchiveInstaller is an installer for archive file.

func NewGzipInstaller

func NewGzipInstaller(fs afero.Fs) *ArchiveInstaller

NewGzipInstaller creates a new filesystem installer.

func NewZipInstaller

func NewZipInstaller(fs afero.Fs) *ArchiveInstaller

NewZipInstaller creates a new filesystem installer.

func (*ArchiveInstaller) Install

func (i *ArchiveInstaller) Install(ctx context.Context, dest, pluginURL string) (*plugin.Plugin, error)

Install installs the plugin.

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer is a file system installer.

func NewFsInstaller

func NewFsInstaller(fs afero.Fs) *Installer

NewFsInstaller creates a new filesystem installer.

func (*Installer) Install

func (i *Installer) Install(ctx context.Context, dest, path string) (*plugin.Plugin, error)

Install installs the plugin.

Jump to

Keyboard shortcuts

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