Documentation
¶
Overview ¶
pkg/utils/utils.go
Index ¶
- Variables
- func BuildUserAgent(name, dependency, platform, version string) string
- func FetchGCPIdentityToken(client *http.Client, audience string) (string, error)
- func GetAvailablePort() (int, error)
- func GetDependencyVersion(dependency string) string
- func GetDynamicMetricsAndProbePorts(defaultMetricsPort, defaultProbePort int) (int, int)
- func GetEnvOrFatal(env string) string
- func GetEnvValueOrDefault(variableName, defaultValue string, enableLogging bool) string
- func ParseTimeInterval(interval, defaultInterval string) time.Duration
- func WaitForKubernetesAPI(clientset kubernetes.Interface, namespace string, timeout time.Duration)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ExitFunc = os.Exit // Function for exiting the application WaitForKubernetesAPIFunc = WaitForKubernetesAPI // Function for mocking RetryInterval = 2 * time.Second // Default values for retry logic, can be overridden externally // GCP Metadata Server URL MetadataServerBaseURL = "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity" // ListenAndServeWrapper wraps the http.ListenAndServe function for testing ListenAndServeWrapper = func(addr string, handler http.Handler) error { server := &http.Server{ Addr: addr, Handler: handler, } listener, err := net.Listen("tcp", addr) if err != nil { logging.Logger().Errorw( "Port already in use or cannot bind", "address", addr, "error", err, ) return err } logging.Logger().Infow( "Server started successfully", "address", addr, ) return server.Serve(listener) } )
Functions ¶
func BuildUserAgent ¶
Build User-Agent string
func FetchGCPIdentityToken ¶
Retrieve GCP Service Account JWT
func GetDependencyVersion ¶
Get the Dependency Version
func GetDynamicMetricsAndProbePorts ¶
Dynamically find ports for the metrics and probe servers (use for avoiding port conflicts during tests)
func GetEnvOrFatal ¶
Retrieves an environment variable or exits if not set
func GetEnvValueOrDefault ¶
Retrieves a variable or if not set, returns the provided default
func ParseTimeInterval ¶
Process time duration
func WaitForKubernetesAPI ¶
func WaitForKubernetesAPI(clientset kubernetes.Interface, namespace string, timeout time.Duration)
WaitForKubernetesAPI waits for the Kubernetes API to be ready within a timeout period
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.