Documentation ¶
Overview ¶
Package pluginutil implements some common functions shared by multiple plugins.
Index ¶
- Variables
- func CleanupJSONField(field string) string
- func CleanupNewLines(s string) string
- func CreateScriptFile(log log.T, scriptPath string, runCommand []string, ...) (err error)
- func DownloadFileFromSource(log log.T, source string, sourceHash string, sourceHashType string) (artifact.DownloadOutput, error)
- func GetProxySetting(proxyValue []string) (string, string)
- func GetShellArguments() []string
- func GetShellCommand() string
- func GetStatus(exitCode int, cancelFlag task.CancelFlag) contracts.ResultStatus
- func LoadParametersAsList(log log.T, prop interface{}, res *contracts.PluginResult) (properties []interface{})
- func LoadParametersAsMap(log log.T, prop interface{}, out iohandler.IOHandler) (properties map[string]interface{})
- func LocalRegistryKeyGetStringsValue(path string, name string) (val []string, valtype uint32, err error)
- func ParseRunCommand(input interface{}, output []string) []string
- func ReadAll(input io.Reader, maxLength int, truncatedSuffix string) (out string, err error)
- func ReadPrefix(input io.Reader, maxLength int, truncatedSuffix string) (out string, err error)
- func ReplaceMarkedFields(str, startMarker, endMarker string, fieldReplacer func(string) string) (newStr string, err error)
- func StringPrefix(input string, maxLength int, truncatedSuffix string) string
- func ValidateExecutionTimeout(log log.T, input interface{}) int
- type MockDefaultPlugin
Constants ¶
This section is empty.
Variables ¶
var ShellArgs = []string{"-c"}
var ShellCommand = "sh"
Functions ¶
func CleanupJSONField ¶
CleanupJSONField converts a text to a json friendly text as follows: - converts multi-line fields to single line by removing all but the first line - escapes special characters - truncates remaining line to length no more than maxSummaryLength
func CleanupNewLines ¶
CleanupNewLines removes all newlines from the given input
func CreateScriptFile ¶
func CreateScriptFile(log log.T, scriptPath string, runCommand []string, byteOrderMark fileutil.ByteOrderMark) (err error)
CreateScriptFile creates a script containing the given commands.
func DownloadFileFromSource ¶
func DownloadFileFromSource(log log.T, source string, sourceHash string, sourceHashType string) (artifact.DownloadOutput, error)
DownloadFileFromSource downloads file from source
func GetProxySetting ¶
GetProxySetting returns proxy setting from registry entries
func GetShellArguments ¶
func GetShellArguments() []string
func GetShellCommand ¶
func GetShellCommand() string
func GetStatus ¶
func GetStatus(exitCode int, cancelFlag task.CancelFlag) contracts.ResultStatus
GetStatus returns a ResultStatus variable based on the received exitCode
func LoadParametersAsList ¶
func LoadParametersAsList(log log.T, prop interface{}, res *contracts.PluginResult) (properties []interface{})
LoadParametersAsList returns properties as a list and appropriate PluginResult if error is encountered
func LoadParametersAsMap ¶
func LoadParametersAsMap(log log.T, prop interface{}, out iohandler.IOHandler) (properties map[string]interface{})
LoadParametersAsMap returns properties as a map and appropriate PluginResult if error is encountered
func ParseRunCommand ¶
ParseRunCommand checks the command type and convert it to the string array
func ReadPrefix ¶
ReadPrefix returns the beginning data from a given Reader, truncated to the given limit.
func ReplaceMarkedFields ¶
func ReplaceMarkedFields(str, startMarker, endMarker string, fieldReplacer func(string) string) (newStr string, err error)
ReplaceMarkedFields finds substrings delimited by the start and end markers, removes the markers, and replaces the text between the markers with the result of calling the fieldReplacer function on that text substring. For example, if the input string is: "a string with <a>text</a> marked" the startMarker is: "<a>" the end marker is: "</a>" and fieldReplacer is: strings.ToUpper then the output will be: "a string with TEXT marked"
func StringPrefix ¶
StringPrefix returns the beginning part of a string, truncated to the given limit.
func ValidateExecutionTimeout ¶
ValidateExecutionTimeout validates the supplied input interface and converts it into a valid int value.
Types ¶
type MockDefaultPlugin ¶
MockDefaultPlugin mocks the default plugin.
func (*MockDefaultPlugin) UploadOutputToS3Bucket ¶
func (m *MockDefaultPlugin) UploadOutputToS3Bucket(log log.T, pluginID string, orchestrationDir string, outputS3BucketName string, outputS3KeyPrefix string, useTempDirectory bool, tempDir string, Stdout string, Stderr string) []string
UploadOutputToS3Bucket is a mocked method that just returns what mock tells it to.