cloudinfo

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 17 Imported by: 3

README

cloudinfo

Get information on the currently running cloud no matter the provider

Adding a cloud provider

Submit the output of the following command in a new issue:

for foo in /sys/class/dmi/id/*; do echo -n "$(basename $foo) = "; cat $foo; done

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DMI

type DMI struct {
	Cloud           string `json:"cloud"`
	Vendor          string `json:"sys_vendor,omitempty"`
	ProductName     string `json:"product_name,omitempty"`
	ProductUUID     string `json:"product_uuid,omitempty"`
	ProductVersion  string `json:"product_version,omitempty"`
	BoardAssetTag   string `json:"board_asset_tag,omitempty"`
	ChassisAssetTag string `json:"chassis_asset_tag,omitempty"`
}

DMI can be used to find various information about the machine

func ReadDMI

func ReadDMI() (*DMI, error)

type IPList

type IPList []netip.Addr

func (IPList) GetFirstV4

func (l IPList) GetFirstV4() (netip.Addr, bool)

GetFirstV4 returns the first IPv4 found in the list

func (IPList) GetFirstV6

func (l IPList) GetFirstV6() (netip.Addr, bool)

GetFirstV6 returns the first IPv6 found in the list

func (IPList) V4

func (l IPList) V4() IPList

V4 returns an IPList with only IPv4 addresses included

func (IPList) V6

func (l IPList) V6() IPList

V6 returns an IPList with only IPv6 addresses included

type Info

type Info struct {
	Provider     string        `json:"provider"`               // provider name code, such as "aws", "gcp", etc
	AccountId    string        `json:"account_id,omitempty"`   // account id with provider
	Architecture string        `json:"architecture,omitempty"` // x86_64
	PublicIP     IPList        `json:"public_ip,omitempty"`
	PrivateIP    IPList        `json:"private_ip,omitempty"`
	Name         string        `json:"name,omitempty"`
	Hostname     string        `json:"hostname,omitempty"`
	Image        string        `json:"image,omitempty"`
	ID           string        `json:"id,omitempty"`
	Type         string        `json:"type,omitempty"`
	Location     LocationArray `json:"location,omitempty"` // structured location
	DMI          *DMI          `json:"dmi,omitempty"`
}

func Load

func Load() (*Info, error)

Load will load & return the info for the current machine. Even if an error happens, a Info structure will be returned containing some basic information.

func Sysinfo

func Sysinfo() *Info

Sysinfo loads and return information available from the local machine (including DMI)

type Location

type Location struct {
	Type  string `json:"type"`  // cloud, region, zone
	Value string `json:"value"` // the actual value
}

func (*Location) String

func (l *Location) String() string

type LocationArray

type LocationArray []*Location

func (LocationArray) Get

func (la LocationArray) Get(typ string) string

func (LocationArray) String

func (la LocationArray) String() string

Jump to

Keyboard shortcuts

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