ecsmetadata

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultEndpoint   = "http://100.100.100.200"
	EnvEndpoint       = "ALIBABA_CLOUD_IMDS_ENDPOINT"
	EnvIMDSV2Disabled = "ALIBABA_CLOUD_IMDSV2_DISABLED"
	EnvIMDSRoleName   = "ALIBABA_CLOUD_ECS_METADATA"
)

Variables

View Source
var DefaultClient, _ = NewClient(ClientOptions{})
View Source
var UserAgent = ""

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opts ClientOptions) (*Client, error)

func (*Client) GetDNSNameServers added in v0.0.8

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

func (*Client) GetDNSNameServersList added in v0.0.9

func (c *Client) GetDNSNameServersList(ctx context.Context) ([]string, error)

func (*Client) GetDiskId added in v0.0.4

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

func (*Client) GetDiskName added in v0.0.4

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

func (*Client) GetDisks added in v0.0.4

func (c *Client) GetDisks(ctx context.Context) ([]string, error)

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context) (*Document, error)

func (*Client) GetEIPV4

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

func (*Client) GetGatewayByMac added in v0.0.4

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

func (*Client) GetHostname added in v0.0.8

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

func (*Client) GetIPV4PrefixesByMac added in v0.0.4

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

func (*Client) GetIPV6GatewayByMac added in v0.0.4

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

func (*Client) GetIPV6sByMac added in v0.0.4

func (c *Client) GetIPV6sByMac(ctx context.Context, mac string) ([]string, error)

func (*Client) GetImageId added in v0.0.4

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

func (*Client) GetInstanceId

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

func (*Client) GetInstanceName

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

func (*Client) GetInstanceType

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

func (*Client) GetInterfaceIdByMac added in v0.0.4

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

func (*Client) GetMac added in v0.0.4

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

func (*Client) GetMacs added in v0.0.4

func (c *Client) GetMacs(ctx context.Context) ([]string, error)

func (*Client) GetMetaData

func (c *Client) GetMetaData(ctx context.Context, method, path string) ([]byte, error)

func (*Client) GetNTPServers added in v0.0.8

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

func (*Client) GetNTPServersList added in v0.0.9

func (c *Client) GetNTPServersList(ctx context.Context) ([]string, error)

func (*Client) GetNetMaskByMac added in v0.0.4

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

func (*Client) GetNetworkType

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

func (*Client) GetOwnerAccountId

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

func (*Client) GetPrimaryIPAddressByMac added in v0.0.4

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

func (*Client) GetPrivateIPV4

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

func (*Client) GetPrivateIPV4sByMac added in v0.0.4

func (c *Client) GetPrivateIPV4sByMac(ctx context.Context, mac string) ([]string, error)

func (*Client) GetPublicIPV4

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

func (*Client) GetRawDocument

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

func (*Client) GetRawRoleCredentials added in v0.0.2

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

func (*Client) GetRegionId

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

func (*Client) GetRoleCredentials added in v0.0.2

func (c *Client) GetRoleCredentials(ctx context.Context, roleName string) (*RoleCredentials, error)

func (*Client) GetRoleName

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

func (*Client) GetSerialNumber added in v0.0.4

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

func (*Client) GetSourceAddress added in v0.0.8

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

func (*Client) GetSourceAddressList added in v0.0.9

func (c *Client) GetSourceAddressList(ctx context.Context) ([]string, error)

func (*Client) GetSpotTerminationTime added in v0.0.6

func (c *Client) GetSpotTerminationTime(ctx context.Context) (time.Time, error)

func (*Client) GetUserData

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

func (*Client) GetVSwitchCidrBlock added in v0.0.8

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

func (*Client) GetVSwitchCidrBlockId

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

GetVSwitchCidrBlockId deprecated, use GetVSwitchCidrBlock instead

func (*Client) GetVSwitchCidrBlockIdByMac added in v0.0.4

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

func (*Client) GetVSwitchIPV6CidrBlockByMac added in v0.0.4

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

func (*Client) GetVSwitchId

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

func (*Client) GetVSwitchIdByMac added in v0.0.4

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

func (*Client) GetVpcCidrBlock added in v0.0.8

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

func (*Client) GetVpcCidrBlockId

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

GetVpcCidrBlockId deprecated, use GetVpcCidrBlock instead

func (*Client) GetVpcIPV6CidrBlocksByMac added in v0.0.4

func (c *Client) GetVpcIPV6CidrBlocksByMac(ctx context.Context, mac string) ([]string, error)

func (*Client) GetVpcId

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

func (*Client) GetVpcIdByMac added in v0.0.4

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

func (*Client) GetZoneId

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

func (*Client) NewDocumentPKCS7Signature

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

func (*Client) SetEndpoint added in v0.0.4

func (c *Client) SetEndpoint(endpoint string) *Client

type ClientOptions

type ClientOptions struct {
	// default: DefaultEndpoint
	Endpoint string
	// ram role of ecs instance
	RoleName      string
	DisableIMDSV2 bool
	// default: 18000, 5 hours
	TokenTTLSeconds int

	TransportWrappers []TransportWrapper

	// default: 30 seconds
	Timeout time.Duration
	// default: time.Now
	NowFunc func() time.Time

	DisableRetry bool
	// default: DefaultRetryOptions()
	RetryOptions *RetryOptions

	UserAgent string
	// contains filtered or unexported fields
}

type Document

type Document struct {
	AccountId      string `json:"account-id"` // always is empty?
	OwnerAccountId string `json:"owner-account-id"`
	InstanceId     string `json:"instance-id"`
	Mac            string `json:"mac"`
	RegionId       string `json:"region-id"`
	SerialNumber   string `json:"serial-number"`
	ZoneId         string `json:"zone-id"`
	InstanceType   string `json:"instance-type"`
	ImageId        string `json:"image-id"`
	PrivateIp      string `json:"private-ip"`
}

type HTTPError

type HTTPError struct {
	URL        string
	StatusCode int
	Header     http.Header
	Body       string

	Err     error
	Message string
}

func (HTTPError) Error

func (e HTTPError) Error() string

func (HTTPError) Unwrap

func (e HTTPError) Unwrap() error

type MockWrapper added in v0.0.4

type MockWrapper struct {
	Mock func(path string) (statusCode int, body string, err error)
}

func (*MockWrapper) RoundTrip added in v0.0.4

func (m *MockWrapper) RoundTrip(req *http.Request) (*http.Response, error)

type RetryOptions

type RetryOptions struct {
	MaxRetryTimes  int
	RetryDelayFunc func(n int) time.Duration
}

func DefaultRetryOptions

func DefaultRetryOptions() *RetryOptions

type RoleCredentials added in v0.0.2

type RoleCredentials struct {
	AccessKeyId     string
	AccessKeySecret string
	SecurityToken   string
	Expiration      time.Time
	LastUpdated     time.Time
	Code            string
}

type TransportWrapper

type TransportWrapper func(rt http.RoundTripper) http.RoundTripper

Jump to

Keyboard shortcuts

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