plugins

package
v0.0.0-...-a114629 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: BSD-3-Clause Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New

func New(l *logger.Logger) *Manager

func (*Manager) Add

func (m *Manager) Add(plugin Plugin) *Manager

func (*Manager) Build

func (m *Manager) Build(parameters *PluginParameter) error

func (*Manager) Size

func (m *Manager) Size() int

func (*Manager) String

func (m *Manager) String() string

type Plugin

type Plugin func(p *PluginParameter) error

func Support

func Support() Plugin

Support is example how we can implement plugins support

func SupportBanner

func SupportBanner() Plugin

SupportBanner will create application info banner

func SupportCluster

func SupportCluster() Plugin

SupportCluster will create clusters when --clusters is exist

func SupportConfig

func SupportConfig(defaultConfig []string) Plugin

SupportConfig will add several things listed below: 1. --pwd for resolve directory (default is current directory) 2. --configs for specify configuration files or directories 3. command 'config' for list config For parameters: defaultPrefix is environment prefix defaultConfig is default configs if no flag provided

func SupportDotEnv

func SupportDotEnv(autoload bool) Plugin

SupportDotEnv will create --envs option for custom load .env files

For parameters:

If autoload is true, it will try to load $PWD/.env and log warn if not exist; otherwise, it will not try to load any thing by default.

func SupportHelp

func SupportHelp() Plugin

SupportHelp will add --help, -h, and help command to show help message

func SupportLogLevel

func SupportLogLevel(defaultLevel logger.Level) Plugin

func SupportVar

func SupportVar() Plugin

SupportVar will add --var "<name>=<value>" for assign data to variables.*

func SupportVersion

func SupportVersion() Plugin

SupportVersion will add '--version', '-v', 'version' to get metadata version

type PluginParameter

type PluginParameter struct {
	Metadata models.Metadata

	NewCommand commands.Creator
	NewFlags   flags.Creator
	NewHook    hooks.Creator

	Config mapper.Mapper
	Logger *logger.Logger
}

Jump to

Keyboard shortcuts

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