azmeta

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MetadataBaseURI is the local Azure metadata endpoint
	MetadataBaseURI = "http://169.254.169.254/metadata/"

	// InstanceAPIVersion is the highest common API version supported across clouds: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service#service-availability
	InstanceAPIVersion = "2019-04-30"

	// ScheduledEventsAPIVersion is the highest version of the API at the time
	ScheduledEventsAPIVersion = "2017-11-01"

	// IdentityAPIVersion is the highest version of the Identity API at the time
	IdentityAPIVersion = "2018-02-01"

	// Freeze the Virtual Machine is scheduled to pause for a few seconds. CPU and network connectivity may be
	// suspended, but there is no impact on memory or open files.
	Freeze EventType = "Freeze"
	// Reboot the Virtual Machine is scheduled for reboot (non-persistent memory is lost).
	Reboot EventType = "Reboot"
	// Redeploy the Virtual Machine is scheduled to move to another node (ephemeral disks are lost).
	Redeploy EventType = "Redeploy"
	// Preempt the Spot Virtual Machine is being deleted (ephemeral disks are lost).
	Preempt EventType = "Preempt"

	// Scheduled signifies this event is scheduled to start after the time specified in the NotBefore property.
	Scheduled EventStatus = "Scheduled"
	// Started signifies this event has started.
	Started EventStatus = "Started"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AckEvent

type AckEvent struct {
	EventID string `json:"EventId"`
}

AckEvent is the event identified for acknowledgement

type AckEvents

type AckEvents struct {
	StartRequests []AckEvent `json:"StartRequests"`
}

AckEvents is a set of event ids to be acknowledged so that Azure can complete the event

type Address

type Address struct {
	PrivateIPAddress string `json:"privateIpAddress,omitempty"`
	PublicIPAddress  string `json:"publicIpAddress,omitempty"`
}

Address describes the public and private IP addresses

type Attestation

type Attestation struct {
	Encoding  string `json:"encoding,omitempty"`
	Signature string `json:"signatrue,omitempty"`
}

Attestation provides a signature and encoding to ensure data is coming from Azure

type Client

type Client struct {
	HTTPClient                *http.Client
	InstanceAPIVersion        string
	IdentityAPIVersion        string
	ScheduledEventsAPIVersion string
	BaseURI                   string
	// contains filtered or unexported fields
}

Client is the HTTP client for the Cloud Partner Portal

func New

func New(opts ...ClientOption) (*Client, error)

New creates a new Azure Metadata client

func (*Client) AckScheduledEvents

func (c *Client) AckScheduledEvents(ctx context.Context, acks AckEvents, middleware ...MiddlewareFunc) error

AckScheduledEvents will acknowledge a set of scheduled events

func (*Client) GetAttestation

func (c *Client) GetAttestation(ctx context.Context, nonce string, middleware ...MiddlewareFunc) (*Attestation, error)

GetAttestation will generate a signed document to verify the data is coming from Azure

nonce is optional and must be digits with a max len of 10; "1234567890" https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service#attested-data

func (*Client) GetIdentityToken

func (c *Client) GetIdentityToken(ctx context.Context, tokenReq ResourceAndIdentity, middleware ...MiddlewareFunc) (*IdentityToken, error)

GetIdentityToken will fetch an authentication token from the instance identity service

func (*Client) GetInstance

func (c *Client) GetInstance(ctx context.Context, middleware ...MiddlewareFunc) (*Instance, error)

GetInstance will fetch the instance metadata from the local machine

func (*Client) GetScheduledEvents

func (c *Client) GetScheduledEvents(ctx context.Context, middleware ...MiddlewareFunc) (*ScheduledEvents, error)

GetScheduledEvents will fetch the scheduled events for the local machine

type ClientOption

type ClientOption func(c *Client) error

ClientOption is a variadic optional configuration func

type Compute

type Compute struct {
	AzureEnvironment     string      `json:"azEnvironment,omitempty"`
	CustomData           string      `json:"customData,omitempty"`
	Location             string      `json:"location,omitempty"`
	Name                 string      `json:"name,omitempty"`
	Offer                string      `json:"offer,omitempty"`
	OSType               string      `json:"osType,omitempty"`
	PlacementGroupID     string      `json:"placementGroupId,omitempty"`
	Plan                 *Plan       `json:"plan,omitempty"`
	PlatformFaultDomain  string      `json:"platformFaultDomain,omitempty"`
	PlatformUpdateDomain string      `json:"platformUpdateDomain,omitempty"`
	Provider             string      `json:"provider,omitempty"`
	PublicKeys           []PublicKey `json:"publicKeys,omitempty"`
	Publisher            string      `json:"publisher,omitempty"`
	ResourceGroupName    string      `json:"resourceGroupName,omitempty"`
	ResourceID           string      `json:"resourceId,omitempty"`
	SKU                  string      `json:"sku,omitempty"`
	SubscriptionID       string      `json:"subscriptionId,omitempty"`
	Tags                 string      `json:"tags,omitempty"`
	Version              string      `json:"version,omitempty"`
	VMID                 string      `json:"vmId,omitempty"`
	VMScaleSetName       string      `json:"vmScaleSetName,omitempty"`
	VMSize               string      `json:"vmSize,omitempty"`
	Zone                 string      `json:"zone,omitempty"`
}

Compute describes the virtual machine details for the instance

type EventStatus

type EventStatus string

EventStatus is the status of the event

Values:

Scheduled:	This event is scheduled to start after the time specified in the NotBefore property.
Started:	This event has started.

No Completed or similar status is ever provided; the event will no longer be returned when the event is completed.

type EventType

type EventType string

EventType is the impact this event causes

Values:

		Freeze: 	The Virtual Machine is scheduled to pause for a few seconds. CPU and network connectivity may be
 					suspended, but there is no impact on memory or open files.
		Reboot: 	The Virtual Machine is scheduled for reboot (non-persistent memory is lost).
		Redeploy: 	The Virtual Machine is scheduled to move to another node (ephemeral disks are lost).
		Preempt: 	The Spot Virtual Machine is being deleted (ephemeral disks are lost).

type IdentityToken

type IdentityToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    string `json:"expires_in"`
	ExpiresOn    string `json:"expires_on"`
	NotBefore    string `json:"not_before"`
	Resource     string `json:"resource"`
	TokenType    string `json:"token_type"`
}

IdentityToken is returned by the identity metadata service (basically an AAD JWT)

use the access token to auth against Azure services

type Instance

type Instance struct {
	Compute *Compute `json:"compute,omitempty"`
	Network *Network `json:"network,omitempty"`
}

Instance is the data structure returned by http://169.254.169.254/metadata/instance

type MiddlewareFunc

type MiddlewareFunc func(next RestHandler) RestHandler

MiddlewareFunc allows a consumer of the Client to inject handlers within the request / response pipeline

The example below adds the atom xml content type to the request, calls the next middleware and returns the result.

addAtomXMLContentType MiddlewareFunc = func(next RestHandler) RestHandler {
		return func(ctx context.Context, req *http.Request) (res *http.Response, e error) {
			if req.Method != http.MethodGet && req.Method != http.MethodHead {
				req.Header.Add("content-Type", "application/atom+xml;type=entry;charset=utf-8")
			}
			return next(ctx, req)
		}
	}

type Network

type Network struct {
	Interfaces []NetworkInterface `json:"interface,omitempty"`
}

Network describes the networking details for the instance

type NetworkInterface

type NetworkInterface struct {
	IPV4       *Protocol `json:"ipv4,omitempty"`
	IPV6       *Protocol `json:"ipv6,omitempty"`
	MacAddress string    `json:"macAddress,omitemtpy"`
}

NetworkInterface describes the protocols and addresses for the nic

type Plan

type Plan struct {
	Name      string `json:"name,omitempty"`
	Product   string `json:"product,omitempty"`
	Publisher string `json:"publisher,omitempty"`
}

Plan describes the VM Plan

type Protocol

type Protocol struct {
	IPAddresses []Address `json:"ipAddress,omitempty"`
	Subnets     []Subnet  `json:"subnet,omitempty"`
}

Protocol describes the IP Addresses and Subnets

type PublicKey

type PublicKey struct {
	KeyData string `json:"keyData,omitempty"`
	Path    string `json:"path,omitempty"`
}

PublicKey describes an ssh public key and the path it should be at on the machine

type ResourceAndIdentity

type ResourceAndIdentity struct {
	Resource          string     `json:"resource,omitempty"`
	ObjectID          *uuid.UUID `json:"object_id,omitempty"`
	ClientID          *uuid.UUID `json:"client_id,omitempty"`
	ManagedIdentityID *string    `json:"mi_res_id,omitempty"` // Azure resource id
}

ResourceAndIdentity is the Azure resource ID and the identity to access that resource

For more info about Azure resource ids: https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/services-support-managed-identities

type RestHandler

type RestHandler func(ctx context.Context, req *http.Request) (*http.Response, error)

RestHandler is used to transform a request and response within the http pipeline

type ScheduledEvent

type ScheduledEvent struct {
	ID           string           `json:"EventID,omitempty"`
	Type         EventType        `json:"EventType,omitempty"`
	ResourceType string           `json:"ResourceType,omitempty"`
	Resources    []string         `json:"Resources,omitempty"`
	Status       EventStatus      `json:"EventStatus,omitempty"`
	NotBefore    date.TimeRFC1123 `json:"NotBefore,omitempty"`
}

ScheduledEvent describes an event which will happen in the future

type ScheduledEvents

type ScheduledEvents struct {
	DocumentIncarnation int              `json:"DocumentIncarnation"`
	Events              []ScheduledEvent `json:"Events"`
}

ScheduledEvents describes a set of events which Azure will execute

type Subnet

type Subnet struct {
	Address string `json:"address,omitempty"`
	Prefix  string `json:"prefix,omitempty"`
}

Subnet describes the subnet for a given protocol

Jump to

Keyboard shortcuts

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