Documentation
¶
Index ¶
- Constants
- Variables
- func Detect()
- func GetAWSAccountID() (string, error)
- func GetAzureSubscriptionID() (string, error)
- func GetGCPProjectID() (string, error)
- func GetHashedInformation() (string, string, bool)
- func GetHashedInformationCached() (string, string, bool)
- func RegisterDefaultDetectors()
- func RegisterDetector(name string, detector DetectorFunc)
- func Reset()
- type DetectorFunc
- type MetadataProvider
Constants ¶
const ( GCPCloud = "gcp_project_numerical_id" AWSCloud = "aws_account_id" AzureCloud = "azure_subscription_id" )
Cloud provider constants
Variables ¶
var ( // ErrNotInCloud is returned when the code is not running in the respective cloud provider ErrNotInCloud = errors.New("not running in cloud provider") )
Functions ¶
func Detect ¶ added in v1.53.0
func Detect()
Detect runs the cloud detection logic and caches the result. Detectors are tried in registration order, and the first one that succeeds is used. Any error is ignored, and the next detector is tried.
func GetAWSAccountID ¶ added in v1.53.0
GetAWSAccountID retrieves AWS account ID using STS.
func GetAzureSubscriptionID ¶ added in v1.53.0
GetAzureSubscriptionID retrieves the Azure Subscription ID using the armsubscriptions package.
func GetGCPProjectID ¶ added in v1.53.0
GetGCPProjectID retrieves the GCP numerical project ID.
func GetHashedInformation ¶ added in v1.53.0
GetHashedInformation returns the detected cloud type, cloud ID (hashed), and detection status.
func GetHashedInformationCached ¶ added in v1.53.0
GetHashedInformationCached returns the detected cloud type, cloud ID (hashed), and detection status.
func RegisterDefaultDetectors ¶ added in v1.54.0
func RegisterDefaultDetectors()
RegisterDefaultDetectors registers the built-in cloud detectors
maintained the order: GCP first, then AWS, then Azure
func RegisterDetector ¶ added in v1.53.0
func RegisterDetector(name string, detector DetectorFunc)
RegisterDetector registers a new cloud detector with the given name
Types ¶
type DetectorFunc ¶ added in v1.53.0
DetectorFunc is a function type that detects a cloud provider and returns its ID
type MetadataProvider ¶
type MetadataProvider struct{}
MetadataProvider collecting cloud environment metadata. Implements the stats.MetadataProvider interface
func NewMetadataProvider ¶ added in v1.53.0
func NewMetadataProvider() *MetadataProvider
NewMetadataProvider creates a new MetadataProvider
func (*MetadataProvider) GetMetadata ¶
GetMetadata returns cloud metadata information as a map It returns the detected cloud type and a hashed version of the cloud ID