Documentation
¶
Index ¶
- Constants
- Variables
- func Detect(storageConfig config.StorageConfig) (string, string, bool)
- func DetectAWSAccountID(storageConfig config.StorageConfig) (string, error)
- func DetectAzureSubscriptionID(config.StorageConfig) (string, error)
- func DetectGCPProjectID(_ config.StorageConfig) (string, error)
- 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") // ErrRequestFailed is returned when a request to the cloud provider fails ErrRequestFailed = errors.New("request failed") )
Functions ¶
func Detect ¶ added in v1.53.0
func Detect(storageConfig config.StorageConfig) (string, string, bool)
Detect cloud type and ID. use the storage config if needed
func DetectAWSAccountID ¶ added in v1.66.0
func DetectAWSAccountID(storageConfig config.StorageConfig) (string, error)
DetectAWSAccountID retrieves AWS account ID using STS. The implementation uses the storage config to help identify the used account id.
func DetectAzureSubscriptionID ¶ added in v1.66.0
func DetectAzureSubscriptionID(config.StorageConfig) (string, error)
DetectAzureSubscriptionID retrieves the Azure Subscription ID using the armsubscriptions package.
func DetectGCPProjectID ¶ added in v1.66.0
func DetectGCPProjectID(_ config.StorageConfig) (string, error)
DetectGCPProjectID retrieves the GCP numerical project ID.
func RegisterDefaultDetectors ¶ added in v1.54.0
func RegisterDefaultDetectors()
RegisterDefaultDetectors registers the built-in cloud detectors
maintain 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
type DetectorFunc func(storageConfig config.StorageConfig) (string, error)
DetectorFunc is a function type that detects a cloud provider and returns its ID
type MetadataProvider ¶
type MetadataProvider struct {
// contains filtered or unexported fields
}
MetadataProvider collecting cloud environment metadata. Implements the stats.MetadataProvider interface
func NewMetadataProvider ¶ added in v1.53.0
func NewMetadataProvider(storageConfig config.StorageConfig, enabled bool) *MetadataProvider
NewMetadataProvider creates a new MetadataProvider and initializes metadata with cloud type and hashed ID if detected.
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