metadata

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 9 Imported by: 4 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Endpoint = "http://169.254.169.254/hetzner/v1/metadata"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the Hetzner Cloud Server Metadata Endpoints.

func NewClient

func NewClient(options ...ClientOption) *Client

NewClient creates a new Client with the options applied.

func (*Client) AvailabilityZone

func (c *Client) AvailabilityZone() (string, error)

AvailabilityZone returns the datacenter of the server that did the request to the Metadata server.

func (*Client) Hostname

func (c *Client) Hostname() (string, error)

Hostname returns the hostname of the server that did the request to the Metadata server.

func (*Client) InstanceID

func (c *Client) InstanceID() (int64, error)

InstanceID returns the ID of the server that did the request to the Metadata server.

func (*Client) IsHcloudServer

func (c *Client) IsHcloudServer() bool

IsHcloudServer checks if the currently called server is a hcloud server by calling a metadata endpoint if the endpoint answers with a non-empty value this method returns true, otherwise false.

func (*Client) PrivateNetworks

func (c *Client) PrivateNetworks() (string, error)

PrivateNetworks returns details about the private networks the server is attached to. Returns YAML (unparsed).

func (*Client) PublicIPv4

func (c *Client) PublicIPv4() (net.IP, error)

PublicIPv4 returns the Public IPv4 of the server that did the request to the Metadata server.

func (*Client) Region

func (c *Client) Region() (string, error)

Region returns the Network Zone of the server that did the request to the Metadata server.

type ClientOption

type ClientOption func(*Client)

A ClientOption is used to configure a Client.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint configures a Client to use the specified Metadata API endpoint.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient configures a Client to perform HTTP requests with httpClient.

func WithInstrumentation

func WithInstrumentation(registry prometheus.Registerer) ClientOption

WithInstrumentation configures a Client to collect metrics about the performed HTTP requests.

func WithTimeout added in v2.1.0

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout specifies a time limit for requests made by this Client. Defaults to 5 seconds.

Jump to

Keyboard shortcuts

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