ec2

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package ec2 provides for converting metadata json to a more ec2-like format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LicenseActivation

type LicenseActivation struct {
	State string `json:"state"`
}

LicenseActivation represents the fields relating to OS license activations

func (*LicenseActivation) GetItem

func (la *LicenseActivation) GetItem(itemPath string) ([]string, bool)

GetItem returns the value for a license activation-related item

func (*LicenseActivation) ItemNames

func (la *LicenseActivation) ItemNames() []string

ItemNames returns the list of license activation-related metadata items

func (*LicenseActivation) TopLevelItemNames

func (la *LicenseActivation) TopLevelItemNames() []string

TopLevelItemNames returns the list of metadata items exposed by this record at the "top level" (that is, the /meta-data endpoint). The License activation record does not expose any top-level items.

type Metadata

type Metadata struct {
	ID              string           `json:"id"`
	Hostname        string           `json:"hostname"`
	IQN             string           `json:"iqn"`
	Plan            string           `json:"plan"`
	Facility        string           `json:"facility"`
	Tags            []string         `json:"tags"`
	OperatingSystem *OperatingSystem `json:"operating_system"`
	SSHKeys         []string         `json:"ssh_keys"`
	Spot            *Spot            `json:"spot"`
	Network         *Network         `json:"network"`
}

Metadata represents the top-level fields of the metadata

func (*Metadata) GetItem

func (metadata *Metadata) GetItem(itemPath string) ([]string, bool)

GetItem takes a string "item path" like "/instance-id" or "/operating-system/slug" and returns a slice of metadata values for the requested item. If metadata doesn't contain a value for the requested item path, it will return an empty slice and false. While most calls will result in just a 1-element slice, Some metadata items might contain more than one value for the requested item (for example, an instance might have more than 1 public IPv4 address).

func (*Metadata) ItemNames

func (metadata *Metadata) ItemNames() []string

ItemNames returns the list of top-level metadata keys that can be subsequently queried by a client. For a Metadata record, this is thee same as the list of "Top Level" item names.

func (*Metadata) TopLevelItemNames

func (metadata *Metadata) TopLevelItemNames() []string

TopLevelItemNames returns the list of metadata items exposed by this record at the "top level" (that is, the /meta-data endpoint).

type MetadataContainer

type MetadataContainer interface {
	ItemNames() []string
	TopLevelItemNames() []string
	GetItem(itemPath string) ([]string, bool)
}

MetadataContainer is an interface defining methods used to access the list of available metadata items as well their individual values

type Network

type Network struct {
	Addresses  []NetworkAddress   `json:"addresses"`
	Bonding    *NetworkBonding    `json:"bonding"`
	Interfaces []NetworkInterface `json:"interfaces"`
}

Network represents the network-related fields in the metadata

func (*Network) GetItem

func (network *Network) GetItem(itemPath string) ([]string, bool)

GetItem returns the value for an operating network-related item

func (*Network) ItemNames

func (network *Network) ItemNames() []string

ItemNames returns the list of network-related metadata items

func (*Network) TopLevelItemNames

func (network *Network) TopLevelItemNames() []string

TopLevelItemNames returns the list of metadata items exposed by this record at the "top level" (that is, the /meta-data endpoint). The network record items are all exposed at the top-level currently, under the aliases "public-ipv4", "public-ipv6", and "local-ipv4".

type NetworkAddress

type NetworkAddress struct {
	ID            string `json:"id"`
	AddressFamily int    `json:"address_family"`
	Netmask       string `json:"netmask"`
	Public        bool   `json:"public"`
	Address       string `json:"address" validate:"ip_addr|cidr"`
}

NetworkAddress represents the fields describing a network address

type NetworkBonding

type NetworkBonding struct {
	Mode int `json:"mode"`
}

NetworkBonding represents network bonding-related information in the metadata

type NetworkInterface

type NetworkInterface struct {
	Name string `json:"name"`
}

NetworkInterface represents fields describing a network interface

type OperatingSystem

type OperatingSystem struct {
	Slug              string             `json:"slug"`
	Distro            string             `json:"distro"`
	Version           string             `json:"version"`
	LicenseActivation *LicenseActivation `json:"license_activation"`
	ImageTag          string             `json:"image_tag"`
}

OperatingSystem represents the fields describing the OS

func (*OperatingSystem) GetItem

func (os *OperatingSystem) GetItem(itemPath string) ([]string, bool)

GetItem returns the value for an operating system-related item

func (*OperatingSystem) ItemNames

func (os *OperatingSystem) ItemNames() []string

ItemNames returns the list of operating system-related metadata items

func (*OperatingSystem) TopLevelItemNames

func (os *OperatingSystem) TopLevelItemNames() []string

TopLevelItemNames returns the list of metadata items exposed by this record at the "top level" (that is, the /meta-data endpoint). For the OperatingSystem record, this is just "operating-system".

type Spot

type Spot struct {
	TerminationTime string `json:"termination_time"`
}

Spot represents the fields describing spot market-related fields

func (*Spot) GetItem

func (spot *Spot) GetItem(itemPath string) ([]string, bool)

GetItem returns the value for a spot-related item.

func (*Spot) ItemNames

func (spot *Spot) ItemNames() []string

ItemNames returns the list of spot market-related metadata items

func (*Spot) TopLevelItemNames

func (spot *Spot) TopLevelItemNames() []string

TopLevelItemNames returns the list of metadata items exposed by this record at the "top level" (that is, the /meta-data endpoint). For a spot record, this is just "spot"

Jump to

Keyboard shortcuts

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