gcpmetadata

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gcpmetadata provides a metadata client for interacting with the Google Cloud metadata server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP client for interacting with the Google Cloud metadata server. No results are cached and each invocation will result in HTTP requests.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new HTTP metadata client for interacting with the Google Cloud metadata server.

func (*Client) Get

func (c *Client) Get(ctx context.Context, pth string) (string, error)

Get fetches the metadata server response at the given path.

func (*Client) ProjectID

func (c *Client) ProjectID(ctx context.Context) (string, error)

ProjectID returns the project ID from the metadata server.

func (*Client) ProjectNumber

func (c *Client) ProjectNumber(ctx context.Context) (string, error)

ProjectNumber returns the project number from the metadata server.

type Option

type Option func(c *Client) *Client

Option is a configuration for the client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient is an option that injects a custom HTTP client.

func WithHost

func WithHost(host string) Option

WithHost is an option that injects a custom metadata server host.

Jump to

Keyboard shortcuts

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