autodetect

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PublicCloudProviders contains the details we use to check which one
	// we are on.
	PublicCloudProviders = Providers{
		"gke": Provider{
			Path:               "/",
			Header:             map[string]string{"Server": "Metadata Server for VM"},
			ExpectedStatusCode: http.StatusOK,
		},
		"do": Provider{
			Path:               "/metadata/v1/id",
			Header:             map[string]string{"Content-Type": "text/plain; charset=utf-8"},
			ExpectedStatusCode: http.StatusOK,
		},
		"eks": Provider{
			Path:               "/",
			Header:             map[string]string{"Server": "EC2ws"},
			ExpectedStatusCode: http.StatusUnauthorized,
		},
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps http.Client so we can mock

func New

func New(hc *http.Client, providers Providers) (*Client, error)

New provides a client to the metadata service

func (*Client) GetProvider

func (c *Client) GetProvider() string

GetProvider attempts to calculate the public cloud provider we are running on

type Provider

type Provider struct {
	Path               string
	Header             map[string]string
	ExpectedStatusCode int
}

Provider stores the details of each cloud provider

type Providers

type Providers map[string]Provider

Providers stores a map of Provider structs

Jump to

Keyboard shortcuts

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