cloud

package
v1.74.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GCPCloud   = "gcp_project_numerical_id"
	AWSCloud   = "aws_account_id"
	AzureCloud = "azure_subscription_id"
)

Cloud provider constants

Variables

View Source
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

func Reset added in v1.53.0

func Reset()

Reset clears all registered detectors, mainly used for testing

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

func (p *MetadataProvider) GetMetadata(ctx context.Context) (map[string]string, error)

GetMetadata returns cloud metadata information as a map It returns the detected cloud type and a hashed version of the cloud ID

Jump to

Keyboard shortcuts

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