cloudproviders

package
v0.0.0-...-31d06e7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package cloudproviders provides utilities to detect the cloud provider.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPreemptible = errors.New("instance is not preemptible")

ErrNotPreemptible is returned when the instance is not a preemptible instance (e.g., not an AWS Spot instance, not a GCE Preemptible instance). When this error is returned, callers should stop polling for preemption events.

View Source
var ErrPreemptionUnsupported = errors.New("preemption detection not supported for this cloud provider")

ErrPreemptionUnsupported is returned when preemption detection is not supported for the given cloud provider.

Functions

func DetectCloudProvider

func DetectCloudProvider(ctx context.Context, collectAccountID bool) (string, string)

DetectCloudProvider detects the cloud provider where the agent is running in order:

func GetCloudProviderNTPHosts

func GetCloudProviderNTPHosts(ctx context.Context) []string

GetCloudProviderNTPHosts detects the cloud provider where the agent is running in order and returns its NTP host name.

func GetHostAliases

func GetHostAliases(ctx context.Context) ([]string, string)

GetHostAliases returns the hostname aliases and the name of the possible cloud providers

func GetHostCCRID

func GetHostCCRID(ctx context.Context, detectedCloud string) string

GetHostCCRID returns the host CCRID from the first provider that works

func GetHostID

func GetHostID(ctx context.Context, cloudProviderName string) string

GetHostID returns the ID for a cloud provider for the current host. The host ID is unique to the cloud provider and is different from the hostname. For now only EC2 is supported.

func GetInstanceType

func GetInstanceType(ctx context.Context, detectedCloud string) string

GetInstanceType returns the instance type from the first cloud provider that works.

func GetPreemptionTerminationTime

func GetPreemptionTerminationTime(ctx context.Context, cloudProviderName string) (time.Time, error)

GetPreemptionTerminationTime returns the scheduled termination time for a preemptible instance (e.g., AWS Spot, GCE Preemptible, Azure Spot). Returns ErrNotPreemptible if the instance is not preemptible. Returns ErrPreemptionUnsupported if the cloud provider doesn't support preemption detection. For now only EC2 is supported.

func GetPublicIPv4

func GetPublicIPv4(ctx context.Context) (string, error)

GetPublicIPv4 returns the public IPv4 from different providers

func GetSource

func GetSource(cloudProviderName string) string

GetSource returns the source used to pull information from the current cloud provider. For now only EC2 is supported. Example of sources for EC2: "IMDSv1", "IMDSv2", "DMI", ...

Types

This section is empty.

Directories

Path Synopsis
Package alibaba provides utilities to detect the Alibaba cloud provider.
Package alibaba provides utilities to detect the Alibaba cloud provider.
Package azure provides utilities to detect Azure cloud provider.
Package azure provides utilities to detect Azure cloud provider.
Package gce provides utilities to detect gce cloud provider.
Package gce provides utilities to detect gce cloud provider.
Package ibm provides utilities to detect ibm cloud provider.
Package ibm provides utilities to detect ibm cloud provider.
Package kubernetes provides utilities to detect cloud provider from kubernetes.
Package kubernetes provides utilities to detect cloud provider from kubernetes.
Package network provides utilities around cloud provider networking.
Package network provides utilities around cloud provider networking.
Package oracle provides utilities to detect oracle cloud provider.
Package oracle provides utilities to detect oracle cloud provider.
Package tencent provides utilities to detect tencent cloud provider.
Package tencent provides utilities to detect tencent cloud provider.

Jump to

Keyboard shortcuts

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