az

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package az provides utility types and functions for Azure SDK.

Index

Constants

View Source
const NilGUID = "00000000-0000-0000-0000-000000000000"

NilGUID is an all-zero GUID.

Variables

This section is empty.

Functions

func EnvForActiveDirectory

func EnvForActiveDirectory(adEndpoint string) *azure.Environment

EnvForActiveDirectory returns the environment for the specified Azure AD endpoint.

func EnvForLocation

func EnvForLocation(loc string) *azure.Environment

EnvForLocation returns the environment for the specified location.

Types

type Cfg

type Cfg struct {
	Src string // Source of config information

	azure.Environment        // Endpoints for the current cloud
	TenantID          string // Active Directory tenant GUID
	SubscriptionID    string // Default subscription GUID
	Location          string // Default location name
	// contains filtered or unexported fields
}

Cfg contains the information necessary to create Azure API clients.

func LoadCfg

func LoadCfg() (*Cfg, error)

LoadCfg loads client configuration, automatically selecting environment variables, SDK auth file, MSI, or CLI config as the source.

func LoadCfgFromCLI

func LoadCfgFromCLI() (*Cfg, error)

LoadCfgFromCLI loads client configuration from Azure CLI.

func LoadCfgFromEnv

func LoadCfgFromEnv(e *Env) (*Cfg, error)

LoadCfgFromEnv loads client configuration from environment variables. If e is nil, the environment is loaded automatically.

func LoadCfgFromFile

func LoadCfgFromFile(name string) (*Cfg, error)

LoadCfgFromFile loads client configuration from an SDK auth file created by 'az ad sp create-for-rbac --sdk-auth' command. The file name defaults to AZURE_AUTH_LOCATION environment variable if empty.

func LoadCfgFromMSI

func LoadCfgFromMSI() (*Cfg, error)

LoadCfgFromMSI loads client configuration from the Managed Service Identity endpoint.

func TestCfg

func TestCfg(url string) *Cfg

TestCfg returns a mock Cfg that can be used for unit testing.

func (*Cfg) Authorizer

func (c *Cfg) Authorizer(resource string) autorest.Authorizer

Authorizer returns an authorizer for the specified resource.

type ComputeMetadata

type ComputeMetadata struct {
	Location             string
	Name                 string
	Offer                string
	OSType               string
	PlacementGroupID     string
	PlatformFaultDomain  string
	PlatformUpdateDomain string
	Publisher            string
	ResourceGroupName    string
	SKU                  string
	SubscriptionID       string
	Tags                 string
	Version              string
	VMID                 string
	VMScaleSetName       string
	VMSize               string
	Zone                 string
}

ComputeMetadata contains basic VM information.

type Env

type Env struct {
	AuthFile       string `env:"AZURE_AUTH_LOCATION"`
	CertPass       string `env:"AZURE_CERTIFICATE_PASSWORD"`
	CertFile       string `env:"AZURE_CERTIFICATE_PATH"`
	ClientID       string `env:"AZURE_CLIENT_ID"`
	ClientSecret   string `env:"AZURE_CLIENT_SECRET"`
	EnvName        string `env:"AZURE_ENVIRONMENT"`
	Location       string `env:"AZURE_LOCATION"`
	SubscriptionID string `env:"AZURE_SUBSCRIPTION"`
	TenantID       string `env:"AZURE_TENANT_ID"`
}

Env defines environment variables used by the SDK (not to be confused with azure.Environment, which defines Azure endpoints).

type InstanceMetadata

type InstanceMetadata struct {
	Compute ComputeMetadata
}

InstanceMetadata contains VM metadata obtained from the Instance Metadata Service (IMDS).

func GetInstanceMetadata

func GetInstanceMetadata() (im InstanceMetadata, err error)

GetInstanceMetadata returns VM metadata from IMDS.

type Paginator

type Paginator struct {
	Err error
	// contains filtered or unexported fields
}

Paginator simplifies API call pagination. Example usage:

rp, err := client.ApiCall()
pg := az.Paginate(&rp, err)
for pg.Next() {
	// Use rp.Response() or rp.Values()
}
if pg.Err != nil {
	// Handler error
}

func Paginate

func Paginate(rp resultPage, err error) Paginator

Paginate returns a simple interface for iterating over all API result pages.

func (*Paginator) Next

func (p *Paginator) Next() bool

Next returns true while there is more data available.

type RID

type RID string

RID is an Azure resource ID. A valid ID must begin with a '/' and contain an even number of path elements, which are interpreted as key/value pairs.

func (RID) Get

func (r RID) Get(key string) string

Get returns the value for the specified key.

func (RID) Name

func (r RID) Name() string

Name returns the last value in r.

func (RID) Norm

func (r RID) Norm() RID

Norm returns a normalized representation of r.

func (RID) Provider

func (r RID) Provider() string

Provider returns the resource provider name.

func (RID) ResourceGroup

func (r RID) ResourceGroup() string

ResourceGroup returns the resource group name.

func (RID) Subscription

func (r RID) Subscription() string

Subscription returns the resource subscription ID.

func (RID) Type

func (r RID) Type() string

Type returns the last key in r or "<type>[/<subtype>[/...]]" if r contains a "/providers/" element.

Jump to

Keyboard shortcuts

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