util

package
v0.0.0-...-3c0e84f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToString

func BoolToString(b bool) string

func ConfigMapToJson

func ConfigMapToJson(configMap map[string]string) (string, error)

func ConvertEpoch

func ConvertEpoch(epoch string) string

func ConvertEpochToTime

func ConvertEpochToTime(epoch string) time.Time

func CreateDir

func CreateDir(path string, mode os.FileMode) error

func DirectoryList

func DirectoryList(path string) ([]string, error)

func EncodeConfig

func EncodeConfig(config Config) (*bytes.Buffer, error)

func EncodePluginConfig

func EncodePluginConfig(configMap map[string]string) (*bytes.Buffer, error)

func ExistsBackupRetention

func ExistsBackupRetention(policy string, retentions []BackupRetention) bool

func ExistsInArray

func ExistsInArray(array []string, str string) bool

func ExistsPath

func ExistsPath(path string) bool

func FileList

func FileList(path string) ([]string, error)

func GetBackupDirFromConfig

func GetBackupDirFromConfig(config Config) string

func GetBackupDirFromMap

func GetBackupDirFromMap(configMap map[string]string) string

func GetBackupName

func GetBackupName(name, policy, workflowId string) string

func GetBackupPathFromConfig

func GetBackupPathFromConfig(config Config) string

func GetBackupPathFromMap

func GetBackupPathFromMap(configMap map[string]string) string

func GetBackupRetention

func GetBackupRetention(policy string, retentions []BackupRetention) int

func GetCronScheduleId

func GetCronScheduleId(w http.ResponseWriter, r *http.Request) (cron.EntryID, error)

func GetLoggerInstance

func GetLoggerInstance() *log.Logger

func GetPluginConfig

func GetPluginConfig(w http.ResponseWriter, r *http.Request) (map[string]string, error)

func GetPluginPath

func GetPluginPath(pluginName string) string

func GetRestoreSrcPath

func GetRestoreSrcPath(config Config) (string, error)

func GetRestoreSrcPathFromMap

func GetRestoreSrcPathFromMap(configMap map[string]string) (string, error)

func GetTimestamp

func GetTimestamp() int64

func GetWorkflowId

func GetWorkflowId() int

func Int64ToString

func Int64ToString(i int64) string

func IntInSlice

func IntInSlice(i int, list []int) bool

func IntToString

func IntToString(i int) string

func JoinArray

func JoinArray(array, combinedArray []string) []string

func LogApi

func LogApi(inner http.Handler, name string) http.Handler

func LogCmdMessage

func LogCmdMessage(l *log.Logger, message string)

func LogCommentMessage

func LogCommentMessage(l *log.Logger, message string)

func LogDebugMessage

func LogDebugMessage(l *log.Logger, message string)

func LogErrorMessage

func LogErrorMessage(l *log.Logger, message string)

func LogInfoMessage

func LogInfoMessage(l *log.Logger, message string)

func LogMessageToConsole

func LogMessageToConsole(l *log.Logger, message Message)

func LogResult

func LogResult(l *log.Logger, result Result)

func LogResults

func LogResults(l *log.Logger, result []Result)

func LogWarnMessage

func LogWarnMessage(l *log.Logger, message string)

func PluginList

func PluginList(path, configName string) ([]string, error)

func ReadConfigToMap

func ReadConfigToMap(filePath string) (map[string]string, error)

func ReadGob

func ReadGob(filePath string, object interface{}) error

func RecursiveDirDelete

func RecursiveDirDelete(dir string) error

func SerializeWorkflow

func SerializeWorkflow(resultsDir string, workflow *Workflow)

func SerializeWorkflowStepResults

func SerializeWorkflowStepResults(resultsDir string, stepId int, results Result)

func SetStepComplete

func SetStepComplete(workflow *Workflow, step Step)

func SetStepError

func SetStepError(workflow *Workflow, step Step)

func SetWorkflowStatusEnd

func SetWorkflowStatusEnd(workflow *Workflow)

func SetWorkflowStatusError

func SetWorkflowStatusError(workflow *Workflow)

func SetWorkflowStatusStart

func SetWorkflowStatusStart(workflow *Workflow)

func SetWorkflowStep

func SetWorkflowStep(workflow *Workflow, step Step)

func StringToInt

func StringToInt(s string) int

func StringToInt64

func StringToInt64(s string) int64

func WriteConfig

func WriteConfig(filePath string, config Config) error

func WriteGob

func WriteGob(filePath string, object interface{}) error

func WritePluginConfig

func WritePluginConfig(filePath string, configMap map[string]string) error

Types

type AppPlugin

type AppPlugin interface {
	SetEnv(Config) Result
	Quiesce(Config) Result
	Unquiesce(Config) Result
	PreRestore(Config) Result
	PostRestore(Config) Result
	Discover(Config) DiscoverResult
	Info() Plugin
}

func GetAppInterface

func GetAppInterface(path string) (AppPlugin, error)

type Archive

type Archive struct {
	Name       string `json:"name,omitempty"`
	Timestamp  string `json:"timestamp,omitempty"`
	Epoch      int    `json:"epoch,omitempty"`
	Policy     string `json:"policy,omitempty"`
	WorkflowId string `json:"workflowId,omitempty"`
}

type ArchivePlugin

type ArchivePlugin interface {
	SetEnv(Config) Result
	Archive(Config) Result
	ArchiveDelete(Config) Result
	ArchiveList(Config) []Archive
	Info() Plugin
}

func GetArchiveInterface

func GetArchiveInterface(path string) (ArchivePlugin, error)

type Archives

type Archives struct {
	Archives []Archive `json:"archive,omitempty"`
	Result   Result    `json:"result,omitempty"`
}

type Backup

type Backup struct {
	Name       string `json:"name,omitempty"`
	Timestamp  string `json:"timestamp,omitempty"`
	Epoch      int    `json:"epoch,omitempty"`
	Policy     string `json:"policy,omitempty"`
	WorkflowId string `json:"workflowId,omitempty"`
}

func GetBackupsByPolicy

func GetBackupsByPolicy(policy string, backups []Backup) []Backup

type BackupRetention

type BackupRetention struct {
	Policy        string `json:"policy"`
	RetentionDays int    `json:"retentionDays"`
}

type Backups

type Backups struct {
	Backups []Backup `json:"backup,omitempty"`
	Result  Result   `json:"result,omitempty"`
}

type ByEpoch

type ByEpoch []Backup

func (ByEpoch) Len

func (a ByEpoch) Len() int

func (ByEpoch) Less

func (a ByEpoch) Less(i, j int) bool

func (ByEpoch) Swap

func (a ByEpoch) Swap(i, j int)

type Capability

type Capability struct {
	Name string `json:"name"`
}

type Config

type Config struct {
	ProfileName             string            `json:"profileName,omitempty"`
	ConfigName              string            `json:"configName,omitempty"`
	WorkflowId              string            `json:"workflowId,omitempty"`
	AppPlugin               string            `json:"appPlugin"`
	StoragePlugin           string            `json:"storagePlugin"`
	ArchivePlugin           string            `json:"archivePlugin"`
	AutoDiscovery           bool              `json:"autoDiscovery"`
	JobRetention            int               `json:"jobRetention"`
	BackupRetentions        []BackupRetention `json:"backupRetentions"`
	SelectedBackupPolicy    string            `json:"backupPolicy,omitmepty"`
	SelectedBackupRetention int               `json:"backupRetention,omitmepty"`
	SelectedWorkflowId      int               `json:"selectedWorkflowId,omitmepty"`
	PreAppQuiesceCmd        string            `json:"preAppQuiesceCmd,omitempty"`
	AppQuiesceCmd           string            `json:"appQuiesceCmd,omitempty"`
	PostAppQuiesceCmd       string            `json:"postAppQuiesceCmd,omitempty"`
	BackupCreateCmd         string            `json:"backupCreateCmd,omitempty"`
	BackupDeleteCmd         string            `json:"backupDeleteCmd,omitempty"`
	ArchiveCreateCmd        string            `json:"archiveCreateCmd,omitempty"`
	ArchiveDeleteCmd        string            `json:"archiveDeleteCmd,omitempty"`
	PreAppUnquiesceCmd      string            `json:"preAppUnquiesceCmd,omitempty"`
	AppUnquiesceCmd         string            `json:"appUnquiesceCmd,omitempty"`
	PostAppUnquiesceCmd     string            `json:"postAppUnquiesceCmd,omitempty"`
	PreAppRestoreCmd        string            `json:"preAppRestoreCmd,omitempty"`
	RestoreCmd              string            `json:"restoreCmd,omitempty"`
	PostAppRestoreCmd       string            `json:"postAppRestoreCmd,omitempty"`
	SendTrapErrorCmd        string            `json:"sendTrapErrorCmd,omitempty"`
	SendTrapSuccessCmd      string            `json:"sendTrapSuccessCmd,omitempty"`
	AppPluginParameters     map[string]string `json:"appPluginParameters,omitempty"`
	StoragePluginParameters map[string]string `json:"storagePluginParameters,omitempty"`
}

func GetConfig

func GetConfig(w http.ResponseWriter, r *http.Request) (Config, error)

func ReadConfig

func ReadConfig(filePath string) (Config, error)

func SetAppPluginParameters

func SetAppPluginParameters(appConfigPath string, config Config) (Config, error)

func SetStoragePluginParameters

func SetStoragePluginParameters(storageConfigPath string, config Config) (Config, error)

type ConfigMapResult

type ConfigMapResult struct {
	ConfigMap map[string]string `json:"configMap,omitmepty"`
	Result    Result            `json:"result,omitmepty"`
}

type ConfigResult

type ConfigResult struct {
	Config Config `json:"config,omitmepty"`
	Result Result `json:"result,omitmepty"`
}

type CronSchedule

type CronSchedule struct {
	Value string `json:"value,omitempty"`
}

func GetCronSchedule

func GetCronSchedule(w http.ResponseWriter, r *http.Request) (CronSchedule, error)

type Discover

type Discover struct {
	Instance      string   `json:"instance,omitempty"`
	DataFilePaths []string `json:"data,omitempty"`
	LogFilePaths  []string `json:"logs,omitempty"`
}

type DiscoverResult

type DiscoverResult struct {
	DiscoverList []Discover `json:"discoverList,omitempty"`
	Result       Result     `json:"result,omitempty"`
}

type Job

type Job struct {
	Id        int    `json:"id,omitempty"`
	Status    string `json:"status,omitempty"`
	Type      string `json:"type,omitempty"`
	Policy    string `json:"policy"`
	Timestamp string `json:"timestamp,omitempty"`
}

func ListJobs

func ListJobs(jobsDir string) ([]Job, error)

type JobSchedule

type JobSchedule struct {
	CronId       cron.EntryID `json:"cronId"`
	CronSchedule string       `json:"cronSchedule"`
	ProfileName  string       `json:"profileName"`
	ConfigName   string       `json:"configName"`
	BackupPolicy string       `json:"backupPolicy"`
}

type JobScheduleResult

type JobScheduleResult struct {
	JobSchedules []JobSchedule `json:"jobSchedules,omitempty"`
	Result       Result        `json:"result,omitempty"`
}

type Jobs

type Jobs struct {
	Jobs   []Job  `json:"backup,omitempty"`
	Result Result `json:"result,omitempty"`
}

type Message

type Message struct {
	Timestamp int64  `json:"time,omitempty"`
	Level     string `json:"level,omitempty"`
	Message   string `json:"message,omitempty"`
}

func PrependMessage

func PrependMessage(message Message, messages []Message) []Message

func PrependMessages

func PrependMessages(prependedMessages, postpendedMessages []Message) []Message

func SetMessage

func SetMessage(level string, msg string) Message

func SetMessages

func SetMessages(inputMessages []string) []Message

type Plugin

type Plugin struct {
	Name         string       `json:"name,omitempty"`
	Description  string       `json:"description,omitempty"`
	Version      string       `json:"version,omitempty"`
	Type         string       `json:"type,omitempty"`
	Capabilities []Capability `json:"capabilities"`
}

type PluginConfigMap

type PluginConfigMap struct {
	Key1 string `json:"key1,omitempty"`
	Key2 string `json:"key2,omitempty"`
}

type PluginInfoResult

type PluginInfoResult struct {
	Plugin Plugin `json:"plugin,omitempty"`
	Result Result `json:"result,omitempty"`
}

type Result

type Result struct {
	Code     int       `json:"code,omitempty"`
	Messages []Message `json:"messages,omitempty"`
	Data     []string  `json:"data,omitempty"`
}

func DeleteJobs

func DeleteJobs(baseDir, profileName, configName string, jobRetention int) Result

func ExecuteCommand

func ExecuteCommand(args ...string) (result Result)

func ExecutePlugin

func ExecutePlugin(config Config, pluginType string, args ...string) (result Result)

func SetResult

func SetResult(code int, messages []Message) Result

func SetResultMessage

func SetResultMessage(code int, level, msg string) Result

type ResultSimple

type ResultSimple struct {
	Code     int      `json:"code,omitempty"`
	Messages []string `json:"messages,omitempty"`
	Data     []string `json:"data,omitempty"`
}

func ExecutePluginSimple

func ExecutePluginSimple(config Config, pluginType string, args ...string) (result ResultSimple)

func SetResultSimple

func SetResultSimple(code int, messages []string) ResultSimple

type Status

type Status struct {
	Msg     string `json:"msg"`
	Version string `json:"version"`
}

type Step

type Step struct {
	Id     int    `json:"id"`
	Status string `json:"status"`
	Label  string `json:"label,omitempty"`
}

func CreateCommentStep

func CreateCommentStep(workflow *Workflow) Step

func CreateStep

func CreateStep(workflow *Workflow) Step

func GetWorkflowSteps

func GetWorkflowSteps(w http.ResponseWriter, r *http.Request) []Step

type StoragePlugin

type StoragePlugin interface {
	SetEnv(Config) Result
	Backup(Config) Result
	Restore(Config) Result
	BackupDelete(Config) Result
	BackupList(Config) Backups
	Info() Plugin
}

func GetStorageInterface

func GetStorageInterface(path string) (StoragePlugin, error)

type Workflow

type Workflow struct {
	Id        int    `json:"id"`
	Status    string `json:"status"`
	Type      string `json:"type"`
	Policy    string `json:"policy"`
	Timestamp string `json:"timestamp,omitempty"`
	Steps     []Step `json:"steps,omitempty"`
}

type WorkflowResult

type WorkflowResult struct {
	Id     int    `json:"id"`
	Result Result `json:"result,omitempty"`
}

type WorkflowStatusResult

type WorkflowStatusResult struct {
	Workflow Workflow `json:"workflow,omitempty"`
	Result   Result   `json:"result,omitempty"`
}

Jump to

Keyboard shortcuts

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