Documentation ¶
Index ¶
- Variables
- func CheckError(err error, msg string) bool
- func CheckProperty(properties map[string]string, property string) (string, error)
- func ConvertMicrosecondsToUnixTime(timeInMicroseconds int64) time.Time
- func CreateTestFileSystem() afero.Fs
- func FailOnError(err error, msg string)
- func GenerateUuidFromConfigId(projectUniqueId string, configId string) (string, error)
- func GenerateUuidFromName(name string) (string, error)
- func IsRequestLoggingActive() bool
- func IsResponseLoggingActive() bool
- func IsUuid(configId string) bool
- func LogRequest(id string, request *http.Request) error
- func LogResponse(id string, response *http.Response) error
- func PrintError(err error)
- func PrintErrors(errors []error)
- func ReplacePathSeparators(path string) (newPath string)
- func SanitizeName(name string) string
- func SetupLogging(verbose bool) error
- func StringTimestampToHumanReadableFormat(unixTimestampAsString string) (humanReadable string, parsedTimestamp int64, err error)
- func UnmarshalYaml(text string, fileName string) (error, map[string]map[string]string)
- func ValidateAndParseJson(jsonString string, filename string) (map[string]interface{}, error)
- func ValidateJson(json string, filename string) error
- type JsonValidationError
- type Template
- type TimelineProvider
Constants ¶
This section is empty.
Variables ¶
var Log lumber.Logger = lumber.NewConsoleLogger(lumber.INFO)
Log is the shared Lumber Logger logging to console and after calling SetupLogging also to file
Functions ¶
func CheckError ¶
func CheckProperty ¶
func ConvertMicrosecondsToUnixTime ¶ added in v1.1.0
ConvertMicrosecondsToUnixTime converts the UTC time in microseconds to a time.Time struct (unix time)
func CreateTestFileSystem ¶ added in v1.5.1
CreateTestFileSystem creates a virtual filesystem with 2 layers. The first layer allows to read file from the disk the second layer allows to modify files on a virtual filesystem
func FailOnError ¶
func GenerateUuidFromConfigId ¶ added in v1.8.0
GenerateUuidFromConfigId takes the unique project identifier within an environment, a config id and generates a valid UUID based on provided information
func GenerateUuidFromName ¶ added in v1.7.0
GenerateUuidFromName generates a fixed UUID from a given configuration name. This is used when dealing with select Dynatrace APIs that do not/or no longer support unique name properties. As a convention between monaco and such APIs, both monaco and Dynatrace will generate the same name-based UUID using UUID v3 (MD5 hash based) with a "dynatrace.com" URL namespace UUID.
func IsRequestLoggingActive ¶ added in v1.3.0
func IsRequestLoggingActive() bool
func IsResponseLoggingActive ¶ added in v1.5.0
func IsResponseLoggingActive() bool
func PrintError ¶ added in v1.5.0
func PrintError(err error)
PrintError should pretty-print the error using a more user-friendly format
func PrintErrors ¶ added in v1.5.0
func PrintErrors(errors []error)
func ReplacePathSeparators ¶
func SanitizeName ¶ added in v1.5.1
SanitizeName removes special characters, limits to max 254 characters in name, no special characters
func SetupLogging ¶
SetupLogging is used to initialize the shared file Logger once the necessary setup config is available
func StringTimestampToHumanReadableFormat ¶ added in v1.1.0
func StringTimestampToHumanReadableFormat(unixTimestampAsString string) (humanReadable string, parsedTimestamp int64, err error)
StringTimestampToHumanReadableFormat parses and sanity-checks a unix timestamp as string and returns it as int64 and a human-readable representation of it
func UnmarshalYaml ¶
UnmarshalYaml takes the contents of a yaml file and converts it to a map[string]map[string]string The yaml file should have the following format:
some-name-1:
- list-key-1: "list-entry-1"
- list-key-2: "list-entry-2"
some-name-2:
- list-key-1: "list-entry-1"
func ValidateAndParseJson ¶ added in v1.3.0
ValidateJson validates whether the json file is correct, by using the internal validation done when unmarshalling to a an object. As none of our jsons can actually be unmarshalled to a string, we catch that error, but report any other error as fatal. We then return the parsed json object.
func ValidateJson ¶ added in v1.1.0
Types ¶
type JsonValidationError ¶ added in v1.1.0
type JsonValidationError struct { // FileName is the file name (full qualified) where the error happened // This field is always filled. FileName string // LineNumber contains the line number (starting by one) where the error happened // If we don't have the information, this is -1. LineNumber int // CharacterNumberInLine contains the character number (starting by one) where // the error happened. If we don't have the information, this is -1. CharacterNumberInLine int // LineContent contains the full line content of where the error happened // If we don't have the information, this is an empty string. LineContent string // PreviousLineContent contains the full line content of the line before LineContent // If we don't have the information, this is an empty string. PreviousLineContent string // Cause is the original error which happened during the json unmarshalling. Cause error }
JsonValidationError is an error which contains more information about where the error appeared in the json file which was validated. It contains the fileName, line number, character number, and line content as additional information. Furthermore, it contains the original error (the cause) which happened during the json unmarshalling.
func (*JsonValidationError) ContainsLineInformation ¶ added in v1.1.0
func (e *JsonValidationError) ContainsLineInformation() bool
ContainsLineInformation indicates whether additional line information is present in the error.
func (JsonValidationError) Error ¶ added in v1.1.0
func (e JsonValidationError) Error() string
func (*JsonValidationError) PrettyPrintError ¶ added in v1.1.0
func (e *JsonValidationError) PrettyPrintError()
type Template ¶
Template wraps the underlying templating logic and provides a means of setting config values just on one place. It is intended to be language-agnostic, the file type does not matter (yaml, json, ...)
func NewTemplate ¶
NewTemplate creates a new template for the given file
type TimelineProvider ¶ added in v1.1.0
type TimelineProvider interface { // Now Returns the current (client-side) time in UTC Now() time.Time // Sleep suspends the current goroutine for the specified duration Sleep(duration time.Duration) }
TimelineProvider abstracts away the time.Now() and time.Sleep(time.Duration) functions to make code unit-testable Whenever you need to get the current time, or want to pause the current goroutine (sleep), please consider using this interface
func NewTimelineProvider ¶ added in v1.1.0
func NewTimelineProvider() TimelineProvider
NewTimelineProvider creates a new TimelineProvider