rportplus

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlusOAuthCapability              = "plus-oauth"
	PlusStatusCapability             = "plus-status"
	PlusLicenseCapability            = "plus-license"
	PlusExtendedPermissionCapability = "plus-extendedpermission"
	PlusAlertingCapability           = "plus-alerting"
)

Variables

View Source
var (
	ErrPlusNotAvailable       = errors.New("rport-plus not enabled/available")
	ErrCapabilityNotAvailable = func(capName string) error { return fmt.Errorf("rport-plus capability (%s) not available", capName) }
)

Functions

func HasLicenseConfig

func HasLicenseConfig(config PlusConfig) bool

func IsOAuthPermittedUserList

func IsOAuthPermittedUserList(config PlusConfig) bool

func IsPlusEnabled

func IsPlusEnabled(config PlusConfig) bool

func IsPlusOAuthEnabled

func IsPlusOAuthEnabled(config PlusConfig) bool

Types

type Capability

type Capability interface {
	GetInitFuncName() (name string)
	InitProvider(sym plugin.Symbol)
	GetConfigValidator() (v validator.Validator)
}

Capability is used to track loaded info about a plugin capability. See the corresponding individual plugin Capability structs.

type Manager

type Manager interface {
	InitPlusManager(cfg *PlusConfig, pluginLoader loader.Loader, logger *logger.Logger)

	// General registry type funcs
	RegisterCapability(capName string, newCap Capability) (cap Capability, err error)
	IsEnabledCapability(capName string) (isEnabled bool)

	// Access specific capabilities
	GetOAuthCapabilityEx() (capEx oauth.CapabilityEx)
	GetStatusCapabilityEx() (capEx status.CapabilityEx)
	GetExtendedPermissionCapabilityEx() (capEx extendedpermission.CapabilityEx)
	GetLicenseCapabilityEx() (capEx licensecap.CapabilityEx)
	GetAlertingCapabilityEx() (capEx alertingcap.CapabilityEx)

	// Access config validation
	GetConfigValidator(capName string) (v validator.Validator)
}

Manager defines the plus manager behavior

type ManagerProvider

type ManagerProvider struct {
	Config *PlusConfig
	// contains filtered or unexported fields
}

ManagerProvider contains a map of all available capabilities and the overall plugin config. The manager is thread safe for reads but not initialization.

func NewPlusManager

func NewPlusManager(ctx context.Context, cfg *PlusConfig, pluginLoader loader.Loader, l *logger.Logger, filesAPI files.FileAPI) (pm *ManagerProvider, err error)

NewPlusManager checks the plugin exists at the specified path, allocates a new plus manager and initializes it

func (*ManagerProvider) GetAlertingCapabilityEx

func (pm *ManagerProvider) GetAlertingCapabilityEx() (capEx alertingcap.CapabilityEx)

GetAlertingCapabilityEx returns a cast version of the Plus Alerting capability

func (*ManagerProvider) GetConfigValidator

func (pm *ManagerProvider) GetConfigValidator(capName string) (v validator.Validator)

GetConfigValidator gets a validator interface that can be invoked to validate the capability config

func (*ManagerProvider) GetExtendedPermissionCapabilityEx

func (pm *ManagerProvider) GetExtendedPermissionCapabilityEx() (capEx extendedpermission.CapabilityEx)

GetExtendedPermissionCapabilityEx returns a cast version of the Plus Extended Permission capability

func (*ManagerProvider) GetLicenseCapabilityEx

func (pm *ManagerProvider) GetLicenseCapabilityEx() (capEx licensecap.CapabilityEx)

GetLicenseCapabilityEx returns a cast version of the Plus License capability

func (*ManagerProvider) GetOAuthCapabilityEx

func (pm *ManagerProvider) GetOAuthCapabilityEx() (capEx oauth.CapabilityEx)

GetOAuthCapability returns a cast version of the OAuth capability

func (*ManagerProvider) GetStatusCapabilityEx

func (pm *ManagerProvider) GetStatusCapabilityEx() (capEx status.CapabilityEx)

GetStatusCapabilityEx returns a cast version of the Plus Status capability

func (*ManagerProvider) InitPlusManager

func (pm *ManagerProvider) InitPlusManager(cfg *PlusConfig, pluginLoader loader.Loader, logger *logger.Logger)

InitPlusManager initializes a plus manager

func (*ManagerProvider) IsEnabledCapability

func (pm *ManagerProvider) IsEnabledCapability(capName string) (isEnabled bool)

IsEnabledCapability returns whether the specified capability is enabled

func (*ManagerProvider) RegisterCapability

func (pm *ManagerProvider) RegisterCapability(capName string, newCap Capability) (cap Capability, err error)

RegisterCapability adds a new plugin capability component, including loading the relevant init func for the capability from the plugin and initializing the capability (via InitProvider)

type PluginConfig

type PluginConfig struct {
	PluginPath string `mapstructure:"plugin_path"`
}

PluginConfig contains the config related to the plugin itself

type PlusConfig

type PlusConfig struct {
	PluginConfig  *PluginConfig   `mapstructure:"plus-plugin"`
	OAuthConfig   *oauth.Config   `mapstructure:"plus-oauth"`
	LicenseConfig *license.Config `mapstructure:"plus-license"`
}

PlusConfig contains the overall config for the rport-plus plugin. note that each capability should have it's own config section in the config file.

Jump to

Keyboard shortcuts

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