Documentation ¶
Overview ¶
represent a basic report
Index ¶
- Constants
- Variables
- func IsEqual(lhs, rhs IReporter) bool
- type BaseReport
- func (report *BaseReport) AddError(er string)
- func (report *BaseReport) GetActionID() string
- func (report *BaseReport) GetActionIDN() int
- func (report *BaseReport) GetActionName() string
- func (report *BaseReport) GetCustomerGUID() string
- func (report *BaseReport) GetDetails() string
- func (report *BaseReport) GetErrorList() []string
- func (report *BaseReport) GetJobID() string
- func (report *BaseReport) GetNextActionId() string
- func (report *BaseReport) GetParentAction() string
- func (report *BaseReport) GetReportID() string
- func (report *BaseReport) GetReporter() string
- func (report *BaseReport) GetStatus() string
- func (report *BaseReport) GetTarget() string
- func (report *BaseReport) GetTimestamp() time.Time
- func (report *BaseReport) InitMutex()
- func (ae *BaseReport) NKeys() int
- func (report *BaseReport) NextActionID()
- func (report *BaseReport) Send() (int, string, error)
- func (report *BaseReport) SendAction(actionName string, sendReport bool, errChan chan<- error)
- func (report *BaseReport) SendAsRoutine(progressNext bool, errChan chan<- error)
- func (report *BaseReport) SendDetails(details string, sendReport bool, errChan chan<- error)
- func (report *BaseReport) SendError(err error, sendReport bool, initErrors bool, errChan chan<- error)
- func (report *BaseReport) SendStatus(status string, sendReport bool, errChan chan<- error)
- func (report *BaseReport) SendWarning(warnMsg string, sendReport bool, initWarnings bool, errChan chan<- error)
- func (report *BaseReport) SetActionID(actionID string)
- func (report *BaseReport) SetActionIDN(actionIDN int)
- func (report *BaseReport) SetActionName(actionName string)
- func (report *BaseReport) SetCustomerGUID(customerGUID string)
- func (report *BaseReport) SetDetails(details string)
- func (report *BaseReport) SetJobID(jobID string)
- func (report *BaseReport) SetParentAction(parentAction string)
- func (report *BaseReport) SetReporter(reporter string)
- func (report *BaseReport) SetStatus(status string)
- func (report *BaseReport) SetTarget(target string)
- func (report *BaseReport) SetTimestamp(timestamp time.Time)
- func (report *BaseReport) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)
- func (reporter *BaseReport) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)
- type BaseReportMock
- func (reportMock *BaseReportMock) AddError(er string)
- func (reportMock *BaseReportMock) GetActionID() string
- func (reportMock *BaseReportMock) GetActionIDN() int
- func (reportMock *BaseReportMock) GetActionName() string
- func (reportMock *BaseReportMock) GetCustomerGUID() string
- func (reportMock *BaseReportMock) GetErrorList() []string
- func (reportMock *BaseReportMock) GetJobID() string
- func (reportMock *BaseReportMock) GetNextActionId() string
- func (reportMock *BaseReportMock) GetParentAction() string
- func (reportMock *BaseReportMock) GetReportID() string
- func (reportMock *BaseReportMock) GetReporter() string
- func (reportMock *BaseReportMock) GetStatus() string
- func (reportMock *BaseReportMock) GetTarget() string
- func (reportMock *BaseReportMock) GetTimestamp() time.Time
- func (reportMock *BaseReportMock) InitMutex()
- func (reportMock *BaseReportMock) NextActionID()
- func (reportMock *BaseReportMock) Send() (int, string, error)
- func (reportMock *BaseReportMock) SendAction(actionName string, sendReport bool)
- func (reportMock *BaseReportMock) SendAsRoutine(collector []string, progressNext bool)
- func (reportMock *BaseReportMock) SendError(err error, sendReport bool, initErrors bool)
- func (reportMock *BaseReportMock) SendStatus(status string, sendReport bool)
- func (reportMock *BaseReportMock) SetActionID(actionID string)
- func (reportMock *BaseReportMock) SetActionIDN(actionIDN int)
- func (reportMock *BaseReportMock) SetActionName(actionName string)
- func (reportMock *BaseReportMock) SetCustomerGUID(customerGUID string)
- func (reportMock *BaseReportMock) SetJobID(jobID string)
- func (reportMock *BaseReportMock) SetParentAction(parentAction string)
- func (reportMock *BaseReportMock) SetReporter(reporter string)
- func (reportMock *BaseReportMock) SetStatus(status string)
- func (reportMock *BaseReportMock) SetTarget(target string)
- func (reportMock *BaseReportMock) SetTimestamp(timestamp time.Time)
- func (reportMock *BaseReportMock) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)
- type IReporter
- type JobsAnnotations
- type StatusType
Constants ¶
Variables ¶
var MAX_RETRIES int = 3
var RETRY_DELAY time.Duration = time.Second * 5
Functions ¶
Types ¶
type BaseReport ¶
type BaseReport struct { CustomerGUID string `json:"customerGUID"` // customerGUID as declared in environment Reporter string `json:"reporter"` // component reporting the event Target string `json:"target"` // wlid, cluster,etc. - which component this event is applicable on Status string `json:"status"` // Action scope: Before action use "started", after action use "failure/success". Reporter scope: Before action use "started", after action use "done". ActionName string `json:"action"` // Stage action. short description of the action to-be-done. When defining an action Errors []string `json:"errors,omitempty"` ActionID string `json:"actionID"` // Stage counter of the E2E process. initialize at 1. The number is increased when sending job report ActionIDN int `json:"numSeq"` // The ActionID in number presentation JobID string `json:"jobID"` // UID received from the eventReceiver after first report (the initializing is part of the first report) ParentAction string `json:"parentAction,omitempty"` // Parent JobID Details string `json:"details,omitempty"` // Details of the action Timestamp time.Time `json:"timestamp"` // // contains filtered or unexported fields }
func NewBaseReport ¶
func NewBaseReport(customerGUID, reporter, eventReceiverUrl string, httpClient httputils.IHttpClient) *BaseReport
NewBaseReport return pointer to new BaseReport obj
func (*BaseReport) AddError ¶
func (report *BaseReport) AddError(er string)
func (*BaseReport) GetActionID ¶
func (report *BaseReport) GetActionID() string
func (*BaseReport) GetActionIDN ¶
func (report *BaseReport) GetActionIDN() int
func (*BaseReport) GetActionName ¶
func (report *BaseReport) GetActionName() string
============================================ GET ============================================
func (*BaseReport) GetCustomerGUID ¶
func (report *BaseReport) GetCustomerGUID() string
func (*BaseReport) GetDetails ¶
func (report *BaseReport) GetDetails() string
func (*BaseReport) GetErrorList ¶
func (report *BaseReport) GetErrorList() []string
func (*BaseReport) GetJobID ¶
func (report *BaseReport) GetJobID() string
func (*BaseReport) GetNextActionId ¶
func (report *BaseReport) GetNextActionId() string
func (*BaseReport) GetParentAction ¶
func (report *BaseReport) GetParentAction() string
func (*BaseReport) GetReportID ¶
func (report *BaseReport) GetReportID() string
func (*BaseReport) GetReporter ¶
func (report *BaseReport) GetReporter() string
func (*BaseReport) GetStatus ¶
func (report *BaseReport) GetStatus() string
func (*BaseReport) GetTarget ¶
func (report *BaseReport) GetTarget() string
func (*BaseReport) GetTimestamp ¶
func (report *BaseReport) GetTimestamp() time.Time
func (*BaseReport) InitMutex ¶
func (report *BaseReport) InitMutex()
func (*BaseReport) NKeys ¶
func (ae *BaseReport) NKeys() int
func (*BaseReport) NextActionID ¶
func (report *BaseReport) NextActionID()
func (*BaseReport) Send ¶
func (report *BaseReport) Send() (int, string, error)
Send - send http request. returns-> http status code, return message (jobID/OK), http/go error
func (*BaseReport) SendAction ¶
func (report *BaseReport) SendAction(actionName string, sendReport bool, errChan chan<- error)
func (*BaseReport) SendAsRoutine ¶
func (report *BaseReport) SendAsRoutine(progressNext bool, errChan chan<- error)
The caller must read the errChan, to prevent the goroutine from waiting in memory forever
func (*BaseReport) SendDetails ¶
func (report *BaseReport) SendDetails(details string, sendReport bool, errChan chan<- error)
func (*BaseReport) SendError ¶
func (report *BaseReport) SendError(err error, sendReport bool, initErrors bool, errChan chan<- error)
SendError - wrap AddError
func (*BaseReport) SendStatus ¶
func (report *BaseReport) SendStatus(status string, sendReport bool, errChan chan<- error)
func (*BaseReport) SendWarning ¶
func (report *BaseReport) SendWarning(warnMsg string, sendReport bool, initWarnings bool, errChan chan<- error)
func (*BaseReport) SetActionID ¶
func (report *BaseReport) SetActionID(actionID string)
func (*BaseReport) SetActionIDN ¶
func (report *BaseReport) SetActionIDN(actionIDN int)
func (*BaseReport) SetActionName ¶
func (report *BaseReport) SetActionName(actionName string)
func (*BaseReport) SetCustomerGUID ¶
func (report *BaseReport) SetCustomerGUID(customerGUID string)
func (*BaseReport) SetDetails ¶
func (report *BaseReport) SetDetails(details string)
func (*BaseReport) SetJobID ¶
func (report *BaseReport) SetJobID(jobID string)
func (*BaseReport) SetParentAction ¶
func (report *BaseReport) SetParentAction(parentAction string)
func (*BaseReport) SetReporter ¶
func (report *BaseReport) SetReporter(reporter string)
func (*BaseReport) SetStatus ¶
func (report *BaseReport) SetStatus(status string)
func (*BaseReport) SetTarget ¶
func (report *BaseReport) SetTarget(target string)
func (*BaseReport) SetTimestamp ¶
func (report *BaseReport) SetTimestamp(timestamp time.Time)
func (*BaseReport) SimpleReportAnnotations ¶
func (report *BaseReport) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)
func (*BaseReport) UnmarshalJSONObject ¶
func (reporter *BaseReport) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)
type BaseReportMock ¶
type BaseReportMock struct {
BaseReport `json:",inline"`
}
BaseReportMock : represents the basic reports from various actions eg. attach and so on
func NewBaseReportMock ¶
func NewBaseReportMock(costumerGUID, reporter string) *BaseReportMock
NewBaseReportMock -
func (*BaseReportMock) AddError ¶
func (reportMock *BaseReportMock) AddError(er string)
func (*BaseReportMock) GetActionID ¶
func (reportMock *BaseReportMock) GetActionID() string
func (*BaseReportMock) GetActionIDN ¶
func (reportMock *BaseReportMock) GetActionIDN() int
func (*BaseReportMock) GetActionName ¶
func (reportMock *BaseReportMock) GetActionName() string
func (*BaseReportMock) GetCustomerGUID ¶
func (reportMock *BaseReportMock) GetCustomerGUID() string
func (*BaseReportMock) GetErrorList ¶
func (reportMock *BaseReportMock) GetErrorList() []string
func (*BaseReportMock) GetJobID ¶
func (reportMock *BaseReportMock) GetJobID() string
func (*BaseReportMock) GetNextActionId ¶
func (reportMock *BaseReportMock) GetNextActionId() string
func (*BaseReportMock) GetParentAction ¶
func (reportMock *BaseReportMock) GetParentAction() string
func (*BaseReportMock) GetReportID ¶
func (reportMock *BaseReportMock) GetReportID() string
func (*BaseReportMock) GetReporter ¶
func (reportMock *BaseReportMock) GetReporter() string
============================================ GET ============================================
func (*BaseReportMock) GetStatus ¶
func (reportMock *BaseReportMock) GetStatus() string
func (*BaseReportMock) GetTarget ¶
func (reportMock *BaseReportMock) GetTarget() string
func (*BaseReportMock) GetTimestamp ¶
func (reportMock *BaseReportMock) GetTimestamp() time.Time
func (*BaseReportMock) InitMutex ¶
func (reportMock *BaseReportMock) InitMutex()
func (*BaseReportMock) NextActionID ¶
func (reportMock *BaseReportMock) NextActionID()
func (*BaseReportMock) SendAction ¶
func (reportMock *BaseReportMock) SendAction(actionName string, sendReport bool)
func (*BaseReportMock) SendAsRoutine ¶
func (reportMock *BaseReportMock) SendAsRoutine(collector []string, progressNext bool)
func (*BaseReportMock) SendError ¶
func (reportMock *BaseReportMock) SendError(err error, sendReport bool, initErrors bool)
SendError - wrap AddError
func (*BaseReportMock) SendStatus ¶
func (reportMock *BaseReportMock) SendStatus(status string, sendReport bool)
func (*BaseReportMock) SetActionID ¶
func (reportMock *BaseReportMock) SetActionID(actionID string)
func (*BaseReportMock) SetActionIDN ¶
func (reportMock *BaseReportMock) SetActionIDN(actionIDN int)
func (*BaseReportMock) SetActionName ¶
func (reportMock *BaseReportMock) SetActionName(actionName string)
func (*BaseReportMock) SetCustomerGUID ¶
func (reportMock *BaseReportMock) SetCustomerGUID(customerGUID string)
func (*BaseReportMock) SetJobID ¶
func (reportMock *BaseReportMock) SetJobID(jobID string)
func (*BaseReportMock) SetParentAction ¶
func (reportMock *BaseReportMock) SetParentAction(parentAction string)
func (*BaseReportMock) SetReporter ¶
func (reportMock *BaseReportMock) SetReporter(reporter string)
============================================ SET ============================================
func (*BaseReportMock) SetStatus ¶
func (reportMock *BaseReportMock) SetStatus(status string)
func (*BaseReportMock) SetTarget ¶
func (reportMock *BaseReportMock) SetTarget(target string)
func (*BaseReportMock) SetTimestamp ¶
func (reportMock *BaseReportMock) SetTimestamp(timestamp time.Time)
func (*BaseReportMock) SimpleReportAnnotations ¶
func (reportMock *BaseReportMock) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)
type IReporter ¶
type IReporter interface { /* send the report @Output: int: http Status Code, string: message: can be jobID for successful 1st report or "OK" from 2nd report onwards or "body could not be fetched" error: error from event receiver */ Send() (int, string, error) //send logic here GetReportID() string /* a multiple errors can occur but these error are not critical, errorString will be added to a vector of errors so the error flow until the critical error will be clear */ AddError(errorString string) GetNextActionId() string NextActionID() /* SimpleReportAnnotations - create an object that can be passed on as annotation and serialize it. This objects can be shared between the different microservices processing the same workload. thus this will save the jobID,it's latest actionID. @Input: setParent- set parentJobID to the jobID setCurrent - set the jobID to the current jobID @returns: jsonAsString, nextActionID */ SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string) /* SendAsRoutine @input: collector []string - leave as empty (a way to hold all previous failed reports and send them in bulk) progressNext bool - increase actionID, sometimes u send parallel jobs that have the same order - (vuln scanning a cluster for eg. all wl scans have the same order) errChan - chan to allow the goroutine to return the errors inside */ SendAsRoutine(bool, chan<- error) //goroutine wrapper // set methods SendAction(action string, sendReport bool, errChan chan<- error) SendError(err error, sendReport bool, initErrors bool, errChan chan<- error) SendStatus(status string, sendReport bool, errChan chan<- error) SendDetails(details string, sendReport bool, errChan chan<- error) SendWarning(warning string, sendReport bool, initWarnings bool, errChan chan<- error) // set methods SetReporter(string) SetStatus(string) SetActionName(string) SetTarget(string) SetActionID(string) SetJobID(string) SetParentAction(string) SetTimestamp(time.Time) SetActionIDN(int) SetCustomerGUID(string) SetDetails(string) // get methods GetReporter() string GetStatus() string GetActionName() string GetTarget() string GetErrorList() []string GetActionID() string GetJobID() string GetParentAction() string GetTimestamp() time.Time GetActionIDN() int GetCustomerGUID() string GetDetails() string }
IReporter reporter interface
type JobsAnnotations ¶
type JobsAnnotations struct { /* jobID: context eg. if a certain job has multiple stages eg. attach namespace>attach wlid in ns so obj when pod is cached should look like: { jobID#1: { "attach namespace" } } - SHOULD BE RETHINK */ // JobIDsContex map[string]string `json:"jobIDsContex,omitempty"` CurrJobID string `json:"jobID"` //simplest case (for now till we have a better idea) ParentJobID string `json:"parentJobID"` //simplest case (for now till we have a better idea) LastActionID string `json:"actionID"` //simplest case (for now till we have a better idea) used to pass as defining ordering between multiple components }
JobsAnnotations job annotation