pluginlib

package module
v0.0.0-...-fa0e601 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2017 License: Apache-2.0 Imports: 12 Imported by: 1

README

wattsPluginLib

A library to make writing WaTTS plugins less tedious.

See watts_plugin_ssh for an example plugin using this library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(err error, exitCode int, msg string)

Check an error and exit with exitCode if it fails

func CheckOk

func CheckOk(ok bool, exitCode int, msg string)

CheckOk check if ok is true and exit with exitCode if not

func PluginDebug

func PluginDebug(debugOutput interface{})

PluginDebug prints the interface and exits. *NOT* for production

func PluginRun

func PluginRun(pluginDescriptor PluginDescriptor)

PluginRun is to be run by the implementing plugin

Types

type Action

type Action (func(Input) Output)

Action is the type of a method implemented by the plugin to execute an action

type AdditionalLogin

type AdditionalLogin struct {
	UserInfo    map[string]string `json:"user_info"`
	AccessToken string            `json:"access_token"`
}

AdditionalLogin type

type ConfigParamsDescriptor

type ConfigParamsDescriptor struct {
	Name    string      `json:"name"`
	Type    string      `json:"type"`
	Default interface{} `json:"default"`
}

ConfigParamsDescriptor for the PluginDescriptor

type Credential

type Credential map[string]interface{}

Credential to be created by request

func AutoCredential

func AutoCredential(name string, value interface{}) (c Credential)

AutoCredential returns a credential which tries to derive type and other attributes

func AutoTextFileCredential

func AutoTextFileCredential(name string, value interface{}, saveAs string) (c Credential)

AutoTextFileCredential returns a credential which tries to derive type and other attributes takes a filename for the case that the credential is a textfile

func TextCredential

func TextCredential(name string, value string) Credential

TextCredential returns a text credential with valid type

func TextFileCredential

func TextFileCredential(name string, value string, rows int, cols int, saveAs string) Credential

TextFileCredential returns a textfile credential with valid type

type FeatureDescriptor

type FeatureDescriptor struct {
	Stdin bool `json:"stdin"`
}

FeatureDescriptor for the PluginDescriptor

type Input

type Input struct {
	WaTTSVersion     string                 `json:"watts_version"`
	Action           string                 `json:"action"`
	Conf             map[string]interface{} `json:"conf_params"`
	Params           map[string]interface{} `json:"params"`
	CredentialState  string                 `json:"cred_state"`
	AccessToken      string                 `json:"access_token"`
	UserInfo         map[string]interface{} `json:"user_info"`
	AdditionalLogins []AdditionalLogin      `json:"additional_logins"`
	WaTTSUserID      string                 `json:"watts_userid"`
}

Input type

func (*Input) PublicKeyFromParams

func (pi *Input) PublicKeyFromParams(key string) (publicKey string)

PublicKeyFromParams get a public key from the parameters also validates the amount of parts of the public key

func (*Input) SSHHostFromConf

func (pi *Input) SSHHostFromConf(userKey string, hostKey string) SSHHost

SSHHostFromConf SSH Host from config values

func (*Input) SSHHostListFromConf

func (pi *Input) SSHHostListFromConf(hostListKey string) SSHHostList

SSHHostListFromConf get ssh hosts from a space separated list of ssh hosts

type Output

type Output map[string]interface{}

Output represents the plugins json output

func PluginAdditionalLogin

func PluginAdditionalLogin(providerID string, userMsg string) Output

PluginAdditionalLogin to be returned by request if an additional login is needed

func PluginError

func PluginError(logMsg string) (o Output)

PluginError call to indicate an error in the logs, but not to the user

func PluginGoodRequest

func PluginGoodRequest(credential []Credential, credentialState string) Output

PluginGoodRequest to be returned by request if the request yielded a credential

func PluginGoodRevoke

func PluginGoodRevoke() Output

PluginGoodRevoke to be returned by revoke if the revoke succeeded

func PluginUserError

func PluginUserError(logMsg string, userMsg string) (o Output)

PluginUserError call to indicate an error in the logs and separately to the user

type PluginDescriptor

type PluginDescriptor struct {
	Author         string
	Version        string
	Description    string
	Name           string
	DeveloperEmail string
	Actions        map[string]Action
	ConfigParams   []ConfigParamsDescriptor
	RequestParams  []RequestParamsDescriptor
	Features       FeatureDescriptor
}

PluginDescriptor describes a plugin to be executed by the wattsPluginLib

type RequestParamsDescriptor

type RequestParamsDescriptor struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Mandatory   bool   `json:"mandatory"`
}

RequestParamsDescriptor for the PluginDescriptor

type SSHHost

type SSHHost string

SSHHost for RunSSHCommand

func (*SSHHost) RunSSHCommand

func (h *SSHHost) RunSSHCommand(cmdParts ...string) (output string)

RunSSHCommand run command the SSHHost

func (*SSHHost) RunSSHCommandErr

func (h *SSHHost) RunSSHCommandErr(cmdParts ...string) (output string, err error)

RunSSHCommandErr like RunSSHCommand, but with error passtrough

type SSHHostList

type SSHHostList []SSHHost

SSHHostList for RunSSHCommand

func (*SSHHostList) RunSSHCommand

func (h *SSHHostList) RunSSHCommand(cmdParts ...string) []string

RunSSHCommand run command on all hosts in the host list

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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