Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticate(env azure.Environment, tenantID string, say func(string), scope string) (*adal.ServicePrincipalToken, error)
- func FindTenantID(env azure.Environment, subscriptionID string) (string, error)
- func IsAzure() bool
- func NewCertOAuthTokenProvider(env azure.Environment, clientID, clientCertPath, tenantID string) (oAuthTokenProvider, error)
- func NewDeviceFlowOAuthTokenProvider(env azure.Environment, say func(string), tenantID string) oAuthTokenProvider
- func NewJWTOAuthTokenProvider(env azure.Environment, clientID, clientJWT, tenantID string) oAuthTokenProvider
- func NewMSIOAuthTokenProvider(env azure.Environment) oAuthTokenProvider
- func NewSecretOAuthTokenProvider(env azure.Environment, clientID, clientSecret, tenantID string) oAuthTokenProvider
- type AzureClientSet
- type AzureClientSetMock
- func (m *AzureClientSetMock) DisksClient() computeapi.DisksClientAPI
- func (m *AzureClientSetMock) ImagesClient() computeapi.ImagesClientAPI
- func (m *AzureClientSetMock) MetadataClient() MetadataClientAPI
- func (m *AzureClientSetMock) PollClient() autorest.Client
- func (m *AzureClientSetMock) VirtualMachineImagesClient() VirtualMachineImagesClientAPI
- func (m *AzureClientSetMock) VirtualMachinesClient() computeapi.VirtualMachinesClientAPI
- type ComputeInfo
- type Config
- func (c *Config) CloudEnvironment() *azure.Environment
- func (c *Config) FillParameters() error
- func (c Config) GetServicePrincipalToken(say func(string), forResource string) (servicePrincipalToken *adal.ServicePrincipalToken, err error)
- func (c Config) GetServicePrincipalTokens(say func(string)) (servicePrincipalToken *adal.ServicePrincipalToken, ...)
- func (c *Config) SetDefaultValues() error
- func (c Config) UseMSI() bool
- func (c Config) Validate(errs *packer.MultiError)
- type MetadataClientAPI
- type PlatformImage
- type VirtualMachineImagesClientAPI
Constants ¶
const DefaultCloudEnvironmentName = "Public"
Variables ¶
var DefaultMetadataClient = NewMetadataClient()
DefaultMetadataClient is the default instance metadata client for Azure. Replace this variable for testing purposes only
Functions ¶
func Authenticate ¶ added in v1.4.5
func Authenticate(env azure.Environment, tenantID string, say func(string), scope string) (*adal.ServicePrincipalToken, error)
Authenticate fetches a token from the local file cache or initiates a consent flow and waits for token to be obtained.
func FindTenantID ¶ added in v1.4.5
func FindTenantID(env azure.Environment, subscriptionID string) (string, error)
FindTenantID figures out the AAD tenant ID of the subscription by making an unauthenticated request to the Get Subscription Details endpoint and parses the value from WWW-Authenticate header.
func IsAzure ¶ added in v1.4.5
func IsAzure() bool
IsAzure returns true if Packer is running on Azure
func NewCertOAuthTokenProvider ¶
func NewCertOAuthTokenProvider(env azure.Environment, clientID, clientCertPath, tenantID string) (oAuthTokenProvider, error)
func NewDeviceFlowOAuthTokenProvider ¶
func NewDeviceFlowOAuthTokenProvider(env azure.Environment, say func(string), tenantID string) oAuthTokenProvider
func NewJWTOAuthTokenProvider ¶
func NewJWTOAuthTokenProvider(env azure.Environment, clientID, clientJWT, tenantID string) oAuthTokenProvider
func NewMSIOAuthTokenProvider ¶
func NewMSIOAuthTokenProvider(env azure.Environment) oAuthTokenProvider
func NewSecretOAuthTokenProvider ¶
func NewSecretOAuthTokenProvider(env azure.Environment, clientID, clientSecret, tenantID string) oAuthTokenProvider
Types ¶
type AzureClientSet ¶ added in v1.4.5
type AzureClientSet interface { MetadataClient() MetadataClientAPI DisksClient() computeapi.DisksClientAPI ImagesClient() computeapi.ImagesClientAPI VirtualMachinesClient() computeapi.VirtualMachinesClientAPI VirtualMachineImagesClient() VirtualMachineImagesClientAPI PollClient() autorest.Client }
func GetTestClientSet ¶ added in v1.4.5
func GetTestClientSet(t *testing.T) (AzureClientSet, error)
type AzureClientSetMock ¶ added in v1.4.5
type AzureClientSetMock struct { DisksClientMock computeapi.DisksClientAPI ImagesClientMock computeapi.ImagesClientAPI VirtualMachineImagesClientMock VirtualMachineImagesClientAPI VirtualMachinesClientMock computeapi.VirtualMachinesClientAPI PollClientMock autorest.Client MetadataClientMock MetadataClientAPI }
AzureClientSetMock provides a generic mock for AzureClientSet
func (*AzureClientSetMock) DisksClient ¶ added in v1.4.5
func (m *AzureClientSetMock) DisksClient() computeapi.DisksClientAPI
DisksClient returns a DisksClientAPI
func (*AzureClientSetMock) ImagesClient ¶ added in v1.4.5
func (m *AzureClientSetMock) ImagesClient() computeapi.ImagesClientAPI
ImagesClient returns a ImagesClientAPI
func (*AzureClientSetMock) MetadataClient ¶ added in v1.4.5
func (m *AzureClientSetMock) MetadataClient() MetadataClientAPI
MetadataClient returns a MetadataClientAPI
func (*AzureClientSetMock) PollClient ¶ added in v1.4.5
func (m *AzureClientSetMock) PollClient() autorest.Client
PollClient returns an autorest Client that can be used for polling async requests
func (*AzureClientSetMock) VirtualMachineImagesClient ¶ added in v1.4.5
func (m *AzureClientSetMock) VirtualMachineImagesClient() VirtualMachineImagesClientAPI
VirtualMachineImagesClient returns a VirtualMachineImagesClientAPI
func (*AzureClientSetMock) VirtualMachinesClient ¶ added in v1.4.5
func (m *AzureClientSetMock) VirtualMachinesClient() computeapi.VirtualMachinesClientAPI
VirtualMachinesClient returns a VirtualMachinesClientAPI
type ComputeInfo ¶ added in v1.4.5
type ComputeInfo struct { Name string ResourceGroupName string SubscriptionID string Location string }
func (ComputeInfo) ResourceID ¶ added in v1.4.5
func (ci ComputeInfo) ResourceID() string
type Config ¶
type Config struct { // One of Public, China, Germany, or // USGovernment. Defaults to Public. Long forms such as // USGovernmentCloud and AzureUSGovernmentCloud are also supported. CloudEnvironmentName string `mapstructure:"cloud_environment_name" required:"false"` // The application ID of the AAD Service Principal. // Requires either `client_secret`, `client_cert_path` or `client_jwt` to be set as well. ClientID string `mapstructure:"client_id"` // A password/secret registered for the AAD SP. ClientSecret string `mapstructure:"client_secret"` // The path to a pem-encoded certificate that will be used to authenticate // as the specified AAD SP. ClientCertPath string `mapstructure:"client_cert_path"` // A JWT bearer token for client auth (RFC 7523, Sec. 2.2) that will be used // to authenticate the AAD SP. Provides more control over token the expiration // when using certificate authentication than when using `client_cert_path`. ClientJWT string `mapstructure:"client_jwt"` // The object ID for the AAD SP. Optional, will be derived from the oAuth token if left empty. ObjectID string `mapstructure:"object_id"` // The Active Directory tenant identifier with which your `client_id` and // `subscription_id` are associated. If not specified, `tenant_id` will be // looked up using `subscription_id`. TenantID string `mapstructure:"tenant_id" required:"false"` // The subscription to use. SubscriptionID string `mapstructure:"subscription_id"` // contains filtered or unexported fields }
Config allows for various ways to authenticate Azure clients. When `client_id` and `subscription_id` are specified, Packer will use the specified Azure Active Directoty (AAD) Service Principal (SP). If only `subscription_id` is specified, Packer will try to interactively log on the current user (tokens will be cached). If none of these options are specified, Packer will attempt to use the Managed Identity and subscription of the VM that Packer is running on. This will only work if Packer is running on an Azure VM.
func (*Config) CloudEnvironment ¶
func (c *Config) CloudEnvironment() *azure.Environment
func (*Config) FillParameters ¶
FillParameters capture the user intent from the supplied parameter set in authType, retrieves the TenantID and CloudEnvironment if not specified. The SubscriptionID is also retrieved in case MSI auth is requested.
func (Config) GetServicePrincipalToken ¶ added in v1.4.5
func (Config) GetServicePrincipalTokens ¶
func (c Config) GetServicePrincipalTokens(say func(string)) ( servicePrincipalToken *adal.ServicePrincipalToken, servicePrincipalTokenVault *adal.ServicePrincipalToken, err error)
func (*Config) SetDefaultValues ¶
func (Config) Validate ¶
func (c Config) Validate(errs *packer.MultiError)
type MetadataClientAPI ¶ added in v1.4.5
type MetadataClientAPI interface {
GetComputeInfo() (*ComputeInfo, error)
}
MetadataClient holds methods that Packer uses to get information about the current VM
func NewMetadataClient ¶ added in v1.4.5
func NewMetadataClient() MetadataClientAPI
NewMetadataClient creates a new instance metadata client
type PlatformImage ¶ added in v1.4.5
type PlatformImage struct {
Publisher, Offer, Sku, Version string
}
func ParsePlatformImageURN ¶ added in v1.4.5
func ParsePlatformImageURN(urn string) (image *PlatformImage, err error)
func (PlatformImage) URN ¶ added in v1.4.5
func (pi PlatformImage) URN() string
type VirtualMachineImagesClientAPI ¶ added in v1.4.5
type VirtualMachineImagesClientAPI interface { computeapi.VirtualMachineImagesClientAPI // extensions GetLatest(ctx context.Context, publisher, offer, sku, location string) (*compute.VirtualMachineImageResource, error) }