Documentation
¶
Overview ¶
Package providers contains machine/cloud providers.
Index ¶
- func SupportsIMDS(d Detector) bool
- func SupportsPrivateIPv4Retry(d Detector) bool
- type Detector
- func New(name string, detectProviderFunc func(ctx context.Context) (string, error), ...) Detector
- func NewIMDSWithRegion(name string, detectProviderFunc func(ctx context.Context) (string, error), ...) Detector
- func NewWithRegion(name string, detectProviderFunc func(ctx context.Context) (string, error), ...) Detector
- type DetectorOption
- type Info
- type RegionDetector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportsIMDS ¶ added in v0.12.26
func SupportsPrivateIPv4Retry ¶ added in v0.12.26
SupportsPrivateIPv4Retry returns true if the detector opted into retrying the private IPv4 fetch (see WithPrivateIPv4Retry).
Types ¶
type Detector ¶
type Detector interface {
// Name returns the name of the provider.
Name() string
// Provider returns a non-empty string and no error,
// if a provider is successfully detected.
Provider(context.Context) (string, error)
// PublicIPv4 returns a non-empty string and no error,
// if a public IPv4 is successfully detected.
PublicIPv4(context.Context) (string, error)
// PrivateIPv4 returns a non-empty string and no error,
// if a private IPv4 is successfully detected.
PrivateIPv4(context.Context) (string, error)
// VMEnvironment returns a non-empty string and no error,
// if a VM environment is successfully detected.
// e.g., "azEnvironment" as "AZUREPUBLICCLOUD" for Azure.
VMEnvironment(context.Context) (string, error)
// InstanceID returns an instance id generated by provider.
InstanceID(ctx context.Context) (string, error)
}
Detector defines a provider detector interface.
func New ¶
func New( name string, detectProviderFunc func(ctx context.Context) (string, error), fetchPublicIPv4Func func(ctx context.Context) (string, error), fetchPrivateIPv4Func func(ctx context.Context) (string, error), fetchVMEnvironmentFunc func(ctx context.Context) (string, error), fetchInstanceIDFunc func(ctx context.Context) (string, error), ) Detector
func NewIMDSWithRegion ¶ added in v0.12.26
func NewIMDSWithRegion( name string, detectProviderFunc func(ctx context.Context) (string, error), fetchPublicIPv4Func func(ctx context.Context) (string, error), fetchPrivateIPv4Func func(ctx context.Context) (string, error), fetchRegionFunc func(ctx context.Context) (string, error), fetchVMEnvironmentFunc func(ctx context.Context) (string, error), fetchInstanceIDFunc func(ctx context.Context) (string, error), opts ...DetectorOption, ) Detector
func NewWithRegion ¶ added in v0.11.7
func NewWithRegion( name string, detectProviderFunc func(ctx context.Context) (string, error), fetchPublicIPv4Func func(ctx context.Context) (string, error), fetchPrivateIPv4Func func(ctx context.Context) (string, error), fetchRegionFunc func(ctx context.Context) (string, error), fetchVMEnvironmentFunc func(ctx context.Context) (string, error), fetchInstanceIDFunc func(ctx context.Context) (string, error), ) Detector
type DetectorOption ¶ added in v0.12.26
type DetectorOption func(*detector)
DetectorOption customizes an IMDS-backed detector.
func WithPrivateIPv4Retry ¶ added in v0.12.26
func WithPrivateIPv4Retry() DetectorOption
WithPrivateIPv4Retry opts the detector into retry-with-backoff for the private IPv4 metadata fetch when it fails or returns empty. Use it only for providers whose metadata service is known to be slow to accept the first connection after an idle period (e.g., nscale); detectors without the option keep single-attempt behavior.
type Info ¶
type Info struct {
Provider string `json:"provider"`
PublicIP string `json:"public_ip"`
PrivateIP string `json:"private_ip"`
Region string `json:"region"`
VMEnvironment string `json:"vm_environment"`
InstanceID string `json:"instance_id"`
IMDSDetected bool `json:"-"`
}
Info defines a provider info data.
func (*Info) RenderTable ¶
type RegionDetector ¶ added in v0.11.7
type RegionDetector interface {
// Region returns a non-empty provider-specific region and no error,
// if a region is successfully detected.
Region(context.Context) (string, error)
}
RegionDetector is implemented by detectors that can report a provider-specific region.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all provides a list of known providers.
|
Package all provides a list of known providers. |
|
Package aws implements "AWS" provider and helpers.
|
Package aws implements "AWS" provider and helpers. |
|
imds
Package imds provides functions for interacting with the AWS Instance Metadata Service.
|
Package imds provides functions for interacting with the AWS Instance Metadata Service. |
|
Package azure implements "azure" provider and helpers.
|
Package azure implements "azure" provider and helpers. |
|
imds
Package imds provides functions for interacting with the Azure Instance Metadata Service.
|
Package imds provides functions for interacting with the Azure Instance Metadata Service. |
|
Package gcp implements Google Cloud Platform (GCP) provider and helpers.
|
Package gcp implements Google Cloud Platform (GCP) provider and helpers. |
|
imds
Package imds provides functions for interacting with the Google Cloud Platform Instance Metadata Service.
|
Package imds provides functions for interacting with the Google Cloud Platform Instance Metadata Service. |
|
imds
Package imds provides functions for interacting with the Nebius Instance Metadata Service.
|
Package imds provides functions for interacting with the Nebius Instance Metadata Service. |
|
Package nscale implements nscale provider detection and metadata helpers.
|
Package nscale implements nscale provider detection and metadata helpers. |
|
imds
Package imds provides functions for interacting with the nscale instance metadata service.
|
Package imds provides functions for interacting with the nscale instance metadata service. |
|
Package oci implements the Oracle Cloud Infrastructure provider detector.
|
Package oci implements the Oracle Cloud Infrastructure provider detector. |
|
imds
Package imds provides functions for interacting with the OCI Instance Metadata Service v2.
|
Package imds provides functions for interacting with the OCI Instance Metadata Service v2. |