plugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package plugin export interfaces to be implemented by application plugins.

The Pluggable interface must be implemented by all plugins.

Other interfaces are optionals and guarded by type assertions. If a plugin type implements a specific interface that plugin will gain specified functionalities.

plugin/manager is responsible for leveraging plugins and their functionalities.

This is not a third-party plugin system where you can load plugins from different sources. The goal is to allow an easy integration for different functionalities while retaining control on code and execution behaviour. Using interfaces allow for plugin modularity and provide a standard integration point. devid is aimed to be a tool to easen and help security posture. Loading arbitrary unverified code from unknown source is not appealing at all in this context. For the time being, all plugins will need to be added manually to the "plugin registry" in plugin/manager package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commander

type Commander interface {
	Commands() []*cobra.Command
}

Commands interface allow a plugin to provide additional commands for devid CLI.

A plugin implementing this interface will be able to add commands to devid CLI.

NOTE that commands will be available independently from the enabled or disabled state of the plugin in the user configuration, as command loading is performed before enablement status is evaluated.

type Configurable

type Configurable interface {
	Configure(v *viper.Viper) error
}

Configurable interface allow a plugin to load configuration from the profile folder.

A plugin implementing this interface will be able to use a part of the Persona configuration file (the YAML object with the same name as the plugin ). Plugin configuration happens before any other action is performed and immediately after reading the Persona configuration file.

type Generated

type Generated struct {
	Executables []GeneratedFile
	Files       []GeneratedFile
}

Generated allow a plugin implementing the Generator interface to return a list of files to be generated.

File generation is then handled by the plugin/manager.

GeneratedFiles added to the Executables slice are made executable, readable and writable by the current user. GeneratedFiles added to the Files slices are written to disk readable and writable only by the current user.

type GeneratedFile

type GeneratedFile struct {
	// Name of the file on disk
	Name string
	// Content of the file
	Content string
}

GeneratedFile represent a single file to be managed by plugin/manager.

type Generator

type Generator interface {
	Generate(location string) (Generated, error)
}

Generator interface allow a plugin to generate content before rendering.

Generation has side effects. To provide a way for the application to cleanup generated artifacts, this method must returns a structure containing information about the artifacts themselves. Filesystem operations are handled by the application and must not be handled the plugin itself.

This allows to provide idempotent generation.

type Pluggable

type Pluggable interface {
	// Name must returns the name of the plugin
	Name() string
}

Pluggable interface allow a plugin to be leveraged.

This interface must be implemented by all plugins.

type Renderable

type Renderable interface {
	// Render should use internal state of the plugin to output a string to be
	// included in the Persona shell loader file.
	Render(name, location string) string
}

Renderable interface allow a plugin to render content in the shell loader and runner files.

type Setuppable

type Setuppable interface {
	Setup(name string) error
}

Setuppable interface allow a plugin to perform setup steps before rendering.

Setup has side effects. Its purpose is to interact with the host system to prepare it for supporting the Persona shell loading.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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