detect

package
v0.0.0-...-24f16ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package detect provides functions to detect the environment the application is running in. It is intended to be used either in a main function or automatically used in a program calling init.Service().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init initializes the environment detection. This should be called as early as possible in the application.

Types

type RunEnv

type RunEnv struct {
	// IsKubernetes is true if the application is running in a Kubernetes cluster.
	IsKubernetes bool
	// IsKind is true if the application is running in a Kind cluster.
	IsKind bool

	// Err is the error that occurred during the detection of the environment.
	Err error

	// IgnoreTesting is a flag to ignore if testing.Testing() is true for the purpose
	// of .Prod() . Normally being in a test environment makes .Prod() return false. But if
	// you are doing a test with a RunEnv and want Prod() to return true, set this to true.
	// This only works in tests.
	IgnoreTesting bool
	// contains filtered or unexported fields
}

RunEnv details the environment the application is running in. TODO: Add more fields, like if we are running in other environments, CCP, underlay, ...

func Env

func Env() RunEnv

Env returns the environment the application is running in.

func (RunEnv) Prod

func (b RunEnv) Prod() bool

Prod checks if the current cluster is a production cluster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL