Documentation
¶
Overview ¶
Package common provides general utility helper functions and types
Index ¶
- func CheckHTTPClientConfigFiles(config *config_util.HTTPClientConfig) ([]string, error)
- func ComputeExternalURL(u, listenAddr string) (*url.URL, error)
- func ConvertMapI2MapS(v any) any
- func GenerateKey(url string) uint64
- func GetFreePort() (int, *net.TCPListener, error)
- func GetUUIDFromString(stringSlice []string) (string, error)
- func MakeConfig[T any](filePath string, expandEnvVars bool) (*T, error)
- func NewGrafanaClient(config *GrafanaWebConfig, logger *slog.Logger) (*grafana.Grafana, error)
- func NodelistParser(nodelistExp string) []string
- func Round(value int64, nearest int64, side string) int64
- func SanitizeFloat(v float64) float64
- func TimeTrack(start time.Time, name string, logger *slog.Logger)
- type GrafanaWebConfig
- type Timespan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckHTTPClientConfigFiles ¶ added in v0.11.0
func CheckHTTPClientConfigFiles(config *config_util.HTTPClientConfig) ([]string, error)
CheckHTTPClientConfigFiles verifies the existence of any files provided in the config and returns all the paths provided in the config. These files paths will be passed to security manager to add ACL rules by the app if and when needed.
func ComputeExternalURL ¶
ComputeExternalURL computes a sanitized external URL from a raw input. It infers unset URL parts from the OS and the given listen address.
func ConvertMapI2MapS ¶
ConvertMapI2MapS walks the given dynamic object recursively, and converts maps with interface{} key type to maps with string key type. This function comes handy if you want to marshal a dynamic object into JSON where maps with interface{} key type are not allowed.
Recursion is implemented into values of the following types:
-map[interface{}]interface{} -map[string]interface{} -[]interface{}
When converting map[interface{}]interface{} to map[string]interface{}, fmt.Sprint() with default formatting is used to convert the key to a string key.
Nicked from https://github.com/icza/dyno
func GenerateKey ¶
GenerateKey generates a reproducible key from a given URL string.
func GetFreePort ¶
func GetFreePort() (int, *net.TCPListener, error)
GetFreePort in this case makes the closing of the listener the responsibility of the caller to allow for a guarantee that multiple random port allocations don't collide.
func GetUUIDFromString ¶
GetUUIDFromString returns a UUID5 for given slice of strings.
func MakeConfig ¶
MakeConfig reads config file, merges with passed default config and returns updated config instance.
func NewGrafanaClient ¶
NewGrafanaClient instantiates a new instance of Grafana client.
func NodelistParser ¶
NodelistParser expands SLURM NODELIST into slice of nodenames.
func Round ¶
Round returns a closest value that is multiple of nearest based on side. If side is `left`, it returns value less or equal to nearest and if the side is `right`, it returns value more or equal to nearest. For every other value of `side`, it returns a value based on `math.Round()`.
func SanitizeFloat ¶
SanitizeFloat replaces +/-Inf and NaN with zero.
Types ¶
type GrafanaWebConfig ¶
type GrafanaWebConfig struct { URL string `yaml:"url"` TeamsIDs []string `yaml:"teams_ids"` HTTPClientConfig config_util.HTTPClientConfig `yaml:",inline"` }
GrafanaWebConfig makes HTTP Grafana config.