Documentation ¶
Index ¶
- Variables
- func AssertFuncAreTheSame(t *testing.T, funcExpected interface{}, funcActual interface{})
- func Btc(t time.Time) func() time.Time
- func Contains(a []string, x string) bool
- func CustomLoggingHandler(router http.Handler, log *logrus.Logger) http.Handler
- func DownloadFile(filepath string, url string) (err error)
- func FileExists(filename string) bool
- func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string
- func FromJSON(str []byte) interface{}
- func Intptr(v int64) *int64
- func IsVersionLessThan(a, b string) bool
- func LoadFixtureHostData(t *testing.T, filename string) model.HostDataBE
- func LoadFixtureHostDataMap(t *testing.T, filename string) model.RawObject
- func LoadFixtureMongoHostDataMap(t *testing.T, filename string) model.RawObject
- func LoadFixtureMongoHostDataMapAsHostData(t *testing.T, filename string) model.HostDataBE
- func LogErr(log *logrus.Logger, err error)
- func NewAPIUrl(baseURL string, username string, password string, path string, ...) *url.URL
- func NewAPIUrlNoParams(baseURL string, username string, password string, path string) *url.URL
- func NewLogger(componentName string) *logrus.Logger
- func NewObjectIDForTests() func() primitive.ObjectID
- func P(s string) time.Time
- func PDT(s string) primitive.DateTime
- func Remove(slice []string, i int) []string
- func SliceToSliceOfInterface(slice interface{}) []interface{}
- func Str2oid(str string) primitive.ObjectID
- func ToIdentedJSON(v interface{}) string
- func ToJSON(v interface{}) string
- func ToJSONMongoCursor(cur *mongo.Cursor) string
- func ToMongoJSON(v interface{}) string
- func WriteAndLogError(log *logrus.Logger, w http.ResponseWriter, statusCode int, err error)
- func WriteExtJSONResponse(log *logrus.Logger, w http.ResponseWriter, statusCode int, resp interface{})
- func WriteJSONResponse(w http.ResponseWriter, statusCode int, resp interface{})
- func WriteNoContentResponse(w http.ResponseWriter)
- func WriteXLSMResponse(w http.ResponseWriter, resp *excelize.File)
- func WriteXLSXResponse(w http.ResponseWriter, resp *excelize.File)
- type AdvancedError
- type AdvancedErrorInterface
- func ParsePrivateKey(raw []byte) (interface{}, interface{}, AdvancedErrorInterface)
- func ParsePublicKey(raw []byte) (interface{}, AdvancedErrorInterface)
- func PatchHostdata(pf model.PatchingFunction, hostdata model.HostDataBE) (model.HostDataBE, AdvancedErrorInterface)
- func Str2bool(in string, defaultValue bool) (bool, AdvancedErrorInterface)
- func Str2float64(in string, defaultValue float64) (float64, AdvancedErrorInterface)
- func Str2int(in string, defaultValue int) (int, AdvancedErrorInterface)
- func Str2time(in string, defaultValue time.Time) (time.Time, AdvancedErrorInterface)
- type ErrorResponseFE
Constants ¶
This section is empty.
Variables ¶
var ErrAlertNotFound = errors.New("Alert not found")
ErrAlertNotFound contains "Alert not found" error
var ErrClusterNotFound = errors.New("Cluster not found")
ErrClusterNotFound contains "Cluster not found" error
var ErrEventEnqueue = errors.New("Failed to enqueue event")
ErrEventEnqueue contains "Failed to enqueue event" error
var ErrHostNotFound = errors.New("Host not found")
ErrHostNotFound contains "Host not found" error
var ErrLicenseNotFound = errors.New("License not found")
ErrLicenseNotFound contains "License not found" error
var ErrNotInClusterHostNotFound = errors.New("Not in cluster host not found")
ErrNotInClusterHostNotFound contains "Baremetal host not found" error
var ErrOracleDatabaseAgreementInvalidPartID = errors.New("Invalid PartID in request")
ErrOracleDatabaseAgreementInvalidPartID contains "Invalid PartID in request" error
var ErrOracleDatabaseAgreementNotFound = errors.New("Agreement not found")
ErrOracleDatabaseAgreementNotFound contains "Agreement not found" error
var ErrOracleDatabaseAssociatedPartNotFound = errors.New("Associated Part not found")
ErrOracleDatabaseAssociatedPartNotFound Associated Part not found
var ErrPatchingFunctionNotFound = errors.New("Patching Function not found")
var MAX_TIME time.Time = time.Now().AddDate(1000, 0, 0)
var MIN_TIME time.Time = time.Unix(0, 0)
Functions ¶
func AssertFuncAreTheSame ¶
AssertFuncAreTheSame tests if funcExpected is the same of funcActual
func CustomLoggingHandler ¶
CustomLoggingHandler return a loggingHandler using ercole formatting
func DownloadFile ¶
DownloadFile download the file from url into the filepath
func FileExists ¶
FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.
func FindNamedMatches ¶
FindNamedMatches return the map of the groups of str
func FromJSON ¶
func FromJSON(str []byte) interface{}
FromJSON convert a json str to interface containing the equivalent json rappresentation
func IsVersionLessThan ¶
IsVersionLessThan return true if a is a version less than b
func LoadFixtureHostData ¶
func LoadFixtureHostData(t *testing.T, filename string) model.HostDataBE
LoadFixtureHostData load the hostdata in the filename and return it
func LoadFixtureHostDataMap ¶
LoadFixtureHostDataMap load the hostdata in the filename and return it
func LoadFixtureMongoHostDataMap ¶
LoadFixtureMongoHostDataMap load the mongohostdata in the filename and return it
func LoadFixtureMongoHostDataMapAsHostData ¶
func LoadFixtureMongoHostDataMapAsHostData(t *testing.T, filename string) model.HostDataBE
LoadFixtureMongoHostDataMapAsHostData load the mongohostdata in the filename and return it as hostdata
func NewAPIUrl ¶
func NewAPIUrl(baseURL string, username string, password string, path string, params url.Values) *url.URL
NewAPIUrl return a new url crafted using the parameters
func NewAPIUrlNoParams ¶
NewAPIUrlNoParams return a new url crafted using the parameters
func NewObjectIDForTests ¶
NewObjectIDForTests is a function to replace NewObjectID in tests that return ids increasing
func SliceToSliceOfInterface ¶
func SliceToSliceOfInterface(slice interface{}) []interface{}
SliceToSliceOfInterface convert a interface to a slice of interface
func ToIdentedJSON ¶
func ToIdentedJSON(v interface{}) string
ToIdentedJSON convert v to a string containing the equivalent idented json rappresentation
func ToJSON ¶
func ToJSON(v interface{}) string
ToJSON convert v to a string containing the equivalent json rappresentation
func ToJSONMongoCursor ¶
ToJSONMongoCursor extract all items from a cursors and return its json rappresentation
func ToMongoJSON ¶
func ToMongoJSON(v interface{}) string
ToMongoJSON convert v to a string containing the equivalent json rappresentation
func WriteAndLogError ¶
WriteAndLogError write the error to the w with the statusCode as statusCode and log the error to the stdout
func WriteExtJSONResponse ¶
func WriteExtJSONResponse(log *logrus.Logger, w http.ResponseWriter, statusCode int, resp interface{})
WriteExtJSONResponse write the statuscode and the response to w
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, statusCode int, resp interface{})
WriteJSONResponse write the statuscode and the response to w
func WriteNoContentResponse ¶
func WriteNoContentResponse(w http.ResponseWriter)
WriteNoContentResponse 204
func WriteXLSMResponse ¶
func WriteXLSMResponse(w http.ResponseWriter, resp *excelize.File)
WriteXLSMResponse for .xlsm files
func WriteXLSXResponse ¶
func WriteXLSXResponse(w http.ResponseWriter, resp *excelize.File)
WriteXLSXResponse for .xlsx fils
Types ¶
type AdvancedError ¶
type AdvancedError struct { // Err contains the base error of the AdvancedError Err error `json:"err"` // Class contains the class of the error Class string `json:"class"` // File contains the filename of the source code where the error was detected Source string `json:"source"` // LineNumber contains the number of the line where the error was detected Line int `json:"line"` }
AdvancedError is a struct that contains informations and class about a error
func NewAdvancedError ¶
func NewAdvancedError(err error, class string) AdvancedError
NewAdvancedError return a new AdvancedError using the err as base error and class as class name
func NewAdvancedErrorPtr ¶
func NewAdvancedErrorPtr(err error, class string) *AdvancedError
NewAdvancedErrorPtr return a pointer to a new AdvancedError using the err as base error and class as class name
func (*AdvancedError) Error ¶
func (ae *AdvancedError) Error() string
Error return the representation string of the error
func (*AdvancedError) ErrorClass ¶
func (ae *AdvancedError) ErrorClass() string
ErrorClass return the class of the error
func (*AdvancedError) LineNumber ¶
func (ae *AdvancedError) LineNumber() int
LineNumber return the line number of the error
func (*AdvancedError) SourceFilename ¶
func (ae *AdvancedError) SourceFilename() string
SourceFilename return the source filename of the error
type AdvancedErrorInterface ¶
type AdvancedErrorInterface interface { error // ErrorClass returns the class of the error ErrorClass() string // SourceFilename returns the filename of the source code where the error was detected SourceFilename() string // LineNumber returns the number of the line where the error was detected LineNumber() int }
AdvancedErrorInterface is a extension of the error interface with other informations
var AerrAlertNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrAlertNotFound, "DB ERROR")
var AerrClusterNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrClusterNotFound, "DB ERROR")
var AerrHostNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrHostNotFound, "DB ERROR")
var AerrLicenseNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrLicenseNotFound, "DB ERROR")
var AerrNotInClusterHostNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrNotInClusterHostNotFound, "DB ERROR")
var AerrOracleDatabaseAgreementInvalidPartID AdvancedErrorInterface = NewAdvancedErrorPtr(ErrOracleDatabaseAgreementInvalidPartID, "CLIENT ERROR")
var AerrOracleDatabaseAgreementNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrOracleDatabaseAgreementNotFound, "DB ERROR")
var AerrOracleDatabaseAssociatedPartNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrOracleDatabaseAssociatedPartNotFound, "DB ERROR")
var AerrPatchingFunctionNotFound AdvancedErrorInterface = NewAdvancedErrorPtr(ErrPatchingFunctionNotFound, "DB ERROR")
func ParsePrivateKey ¶
func ParsePrivateKey(raw []byte) (interface{}, interface{}, AdvancedErrorInterface)
ParsePrivateKey converts a private key expressed as []byte to interface{}
func ParsePublicKey ¶
func ParsePublicKey(raw []byte) (interface{}, AdvancedErrorInterface)
ParsePublicKey converts a private key expressed as []byte to interface{}
func PatchHostdata ¶
func PatchHostdata(pf model.PatchingFunction, hostdata model.HostDataBE) (model.HostDataBE, AdvancedErrorInterface)
PatchHostdata patch a single hostdata using the pf PatchingFunction. It doesn't check if pf.Hostname equals hostdata["Hostname"]
func Str2bool ¶
func Str2bool(in string, defaultValue bool) (bool, AdvancedErrorInterface)
Str2bool parse a string to a boolean
func Str2float64 ¶
func Str2float64(in string, defaultValue float64) (float64, AdvancedErrorInterface)
Str2float64 parse a string to a float64
type ErrorResponseFE ¶
type ErrorResponseFE struct { // Error contains the (generic) class of the error Error string `json:"error"` // ErrorDescription contains detailed informations about the error ErrorDescription string `json:"errorDescription"` // File contains the filename of the source code where the error was detected SourceFilename string `json:"sourceFilename"` // LineNumber contains the number of the line where the error was detected LineNumber int `json:"lineNumber"` }
ErrorResponseFE is a struct that contains informations about a error