metadata

package
v0.0.0-...-05f333e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	BlockProjectKeys      bool
	EnableOSLogin         *bool
	EnableWindowsSSH      *bool
	TwoFactor             *bool
	SecurityKey           *bool
	RequireCerts          *bool
	SSHKeys               []string
	WindowsKeys           WindowsKeys
	Diagnostics           string
	DisableAddressManager *bool
	DisableAccountManager *bool
	EnableDiagnostics     *bool
	EnableWSFC            *bool
	WSFCAddresses         string
	WSFCAgentPort         string
	DisableTelemetry      bool
}

Attributes describes the project's attributes keys.

func (*Attributes) UnmarshalJSON

func (a *Attributes) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into Attribute.

type Client

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

Client defines the public interface between the core guest agent and the metadata layer.

func New

func New() *Client

New allocates and configures a new Client instance.

func (*Client) Get

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

Get does a metadata call, if hang is set to true then it will do a longpoll.

func (*Client) GetKey

func (c *Client) GetKey(ctx context.Context, key string, headers map[string]string) (string, error)

GetKey gets a specific metadata key.

func (*Client) GetKeyRecursive

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

GetKeyRecursive gets a specific metadata key recursively and returns JSON output.

func (*Client) Watch

func (c *Client) Watch(ctx context.Context) (*Descriptor, error)

Watch runs a longpoll on metadata server.

func (*Client) WriteGuestAttributes

func (c *Client) WriteGuestAttributes(ctx context.Context, key, value string) error

WriteGuestAttributes does a put call to mds changing a guest attribute value.

type Descriptor

type Descriptor struct {
	Instance Instance
	Project  Project
}

Descriptor wraps/holds all the metadata keys, the structure reflects the json descriptor returned with metadata call with alt=jason.

func (*Descriptor) UnmarshalJSON

func (m *Descriptor) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into Descritor.

type Instance

type Instance struct {
	// ID is the instance ID.
	ID json.Number

	// MachineType represents the instance's machine type.
	MachineType string

	// Attributes are the instance's attributes.
	Attributes Attributes

	// NetworkInterfaces contains all configured regular network interfaces (primary and secondary).
	NetworkInterfaces []NetworkInterfaces

	// VlanNetworkInterfaces contains all the vLAN network interfaces.
	VlanNetworkInterfaces []map[int]VlanInterface

	// VirtualClock contains the drift-token attribute.
	VirtualClock virtualClock
}

Instance describes the metadata's instance attributes/keys.

type MDSClientInterface

type MDSClientInterface interface {
	Get(context.Context) (*Descriptor, error)
	GetKey(context.Context, string, map[string]string) (string, error)
	GetKeyRecursive(context.Context, string) (string, error)
	Watch(context.Context) (*Descriptor, error)
	WriteGuestAttributes(context.Context, string, string) error
}

MDSClientInterface is the minimum required Metadata Server interface for Guest Agent.

type MDSReqError

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

MDSReqError represents custom error produced by HTTP requests made on MDS. It captures error and HTTP response for inspecting status code.

func (*MDSReqError) Error

func (m *MDSReqError) Error() string

Error implements method defined on error interface to transform custom type into error.

type NetworkInterfaces

type NetworkInterfaces struct {
	ForwardedIps      []string
	ForwardedIpv6s    []string
	TargetInstanceIps []string
	IPAliases         []string
	Mac               string
	DHCPv6Refresh     string
}

NetworkInterfaces describes the instances network interfaces configurations.

type Project

type Project struct {
	Attributes       Attributes
	ProjectID        string
	NumericProjectID json.Number
}

Project describes the projects instance's attributes.

type VlanInterface

type VlanInterface struct {
	// Mac is the vLAN interface's mac address.
	Mac string

	// ParentInterface is the mds reference of the parent/physical interface i.e.:
	// /computeMetadata/v1/instance/network-interfaces/0/
	ParentInterface string

	// Vlan is the vlan id.
	Vlan int

	// MTU is the vlan's MTU value.
	MTU int

	// IP is the vlan's ip address.
	IP string

	// IPv6 is the vlan's ipv6 address.
	IPv6 []string

	// Gateway is the vlan's gateway address.
	Gateway string

	// GatewayIPv6 is the vlan's IPv6 gateway address.
	GatewayIPv6 string
}

VlanInterface describes the instances vlan network interfaces configurations.

type WindowsKey

type WindowsKey struct {
	Email               string
	ExpireOn            string
	Exponent            string
	Modulus             string
	UserName            string
	HashFunction        string
	AddToAdministrators *bool
	PasswordLength      int
}

WindowsKey describes the WindowsKey metadata keys.

type WindowsKeys

type WindowsKeys []WindowsKey

WindowsKeys is a slice of WindowKey.

func (*WindowsKeys) UnmarshalJSON

func (k *WindowsKeys) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into WindowsKeys.

Jump to

Keyboard shortcuts

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