Documentation
¶
Overview ¶
Package utils provides utility functions for environment variable management.
Index ¶
- func CompareTimeStrings(left, right string) int
- func GetEnvironmentVariable(name string, others ...any) string
- func GetEnvironmentVariableAsInteger(name string, others ...any) (int, error)
- func JoinURL(base string, parts ...string) string
- func ParseSecretsYAML(s string) (map[string]string, error)
- func ParseTimeString(value string) (time.Time, error)
- func SecretsToAny(secrets map[string]string) map[string]any
- func TimeStringAfter(left, right string) bool
- func TimeStringBefore(left, right string) bool
- type CredimiError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareTimeStrings ¶
CompareTimeStrings compares timestamp strings chronologically.
func GetEnvironmentVariable ¶
GetEnvironmentVariable retrieves the value of an environment variable.
Parameters:
- name: The name of the environment variable to retrieve.
- defaultValue (if provided): The value to return if the environment variable is not set.
- required (if provided): A boolean indicating whether the environment variable is required.
Returns:
- string: The value of the environment variable, or the default value if not set. If the variable is required and not set, the function panics.
func GetEnvironmentVariableAsInteger ¶
GetEnvironmentVariableAsInteger retrieves the value of an environment variable and converts it to an integer.
Parameters:
- name: The name of the environment variable to retrieve.
- others: Optional variadic parameters:
- First parameter (if provided): The default integer value to return if the environment variable is not set or empty.
- Second parameter (if provided): A boolean indicating whether the environment variable is required.
Returns:
int: The integer value of the environment variable, or the default value if not set or empty.
error: An error if the environment variable cannot be parsed as an integer or if the value is out of range for int.
Returns nil if no error occurred.
func JoinURL ¶
JoinURL appends path parts to a base URL and returns the original base when the input cannot be parsed, avoiding nil dereferences in callers.
func ParseSecretsYAML ¶
ParseSecretsYAML parses a YAML mapping of secret names to values. An empty string returns nil, nil.
func ParseTimeString ¶
ParseTimeString parses timestamps produced by Temporal and PocketBase APIs.
func SecretsToAny ¶
SecretsToAny converts parsed secrets to the map[string]any form carried by activity results and API responses. Empty secrets return nil.
func TimeStringAfter ¶
TimeStringAfter reports whether left is chronologically after right.
func TimeStringBefore ¶
TimeStringBefore reports whether left is chronologically before right.