Documentation ¶
Index ¶
- func AuthenticateDeviceFlow(env azure.Environment, subscriptionID string) (*azure.ServicePrincipalToken, error)
- func AuthenticateServicePrincipal(env azure.Environment, subscriptionID, spID, spPassword string) (*azure.ServicePrincipalToken, error)
- type AzureClient
- func (a AzureClient) CleanupAvailabilitySetIfExists(resourceGroup, name string) error
- func (a AzureClient) CleanupSubnetIfExists(resourceGroup, virtualNetwork, name string) error
- func (a AzureClient) CleanupVirtualNetworkIfExists(resourceGroup, name string) error
- func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error
- func (a AzureClient) CreateNetworkInterface(ctx *DeploymentContext, ...) error
- func (a AzureClient) CreateNetworkSecurityGroup(ctx *DeploymentContext, resourceGroup, name, location string, ...) error
- func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool, ...) error
- func (a AzureClient) CreateResourceGroup(name, location string) error
- func (a AzureClient) CreateStorageAccount(ctx *DeploymentContext, resourceGroup, location string, ...) error
- func (a AzureClient) CreateSubnet(ctx *DeploymentContext, ...) error
- func (a AzureClient) CreateVirtualMachine(...) error
- func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, location string) error
- func (a AzureClient) DeleteNetworkInterfaceIfExists(resourceGroup, name string) error
- func (a AzureClient) DeleteNetworkSecurityGroupIfExists(resourceGroup, name string) error
- func (a AzureClient) DeletePublicIPAddressIfExists(resourceGroup, name string) error
- func (a AzureClient) DeleteVirtualMachineIfExists(resourceGroup, name string) error
- func (a AzureClient) GetAvailabilitySet(resourceGroup, name string) (compute.AvailabilitySet, error)
- func (a AzureClient) GetPrivateIPAddress(resourceGroup, name string) (string, error)
- func (a AzureClient) GetPublicIPAddress(resourceGroup, name string, useFqdn bool) (string, error)
- func (a AzureClient) GetSubnet(resourceGroup, virtualNetwork, name string) (network.Subnet, error)
- func (a AzureClient) GetVirtualMachinePowerState(resourceGroup, name string) (VMPowerState, error)
- func (a AzureClient) RegisterResourceProviders(namespaces ...string) error
- func (a AzureClient) RestartVirtualMachine(resourceGroup, name string) error
- func (a AzureClient) StartVirtualMachine(resourceGroup, name string) error
- func (a AzureClient) StopVirtualMachine(resourceGroup, name string) error
- func (a AzureClient) VirtualMachineExists(resourceGroup, name string) (bool, error)
- type DeploymentContext
- type ResourceNaming
- type VMPowerState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticateDeviceFlow ¶ added in v0.9.0
func AuthenticateDeviceFlow(env azure.Environment, subscriptionID string) (*azure.ServicePrincipalToken, error)
AuthenticateDeviceFlow fetches a token from the local file cache or initiates a consent flow and waits for token to be obtained. Obtained token is stored in a file cache for future use and refreshing.
func AuthenticateServicePrincipal ¶ added in v0.9.0
func AuthenticateServicePrincipal(env azure.Environment, subscriptionID, spID, spPassword string) (*azure.ServicePrincipalToken, error)
AuthenticateServicePrincipal uses given service principal credentials to return a service principal token. Generated token is not stored in a cache file or refreshed.
Types ¶
type AzureClient ¶
type AzureClient struct {
// contains filtered or unexported fields
}
func New ¶
func New(env azure.Environment, subsID string, auth autorest.Authorizer) *AzureClient
func (AzureClient) CleanupAvailabilitySetIfExists ¶
func (a AzureClient) CleanupAvailabilitySetIfExists(resourceGroup, name string) error
CleanupAvailabilitySetIfExists removes an availability set if there are no virtual machines attached to it. Note that this method is not safe for multiple concurrent writers, in case of races, deployment of a machine could fail or resource might not be cleaned up.
func (AzureClient) CleanupSubnetIfExists ¶
func (a AzureClient) CleanupSubnetIfExists(resourceGroup, virtualNetwork, name string) error
CleanupSubnetIfExists removes a subnet if there are no IP configurations (through NICs) are attached to it. Note that this method is not safe for multiple concurrent writers, in case of races, deployment of a machine could fail or resource might not be cleaned up.
func (AzureClient) CleanupVirtualNetworkIfExists ¶
func (a AzureClient) CleanupVirtualNetworkIfExists(resourceGroup, name string) error
CleanupVirtualNetworkIfExists removes a subnet if there are no subnets attached to it. Note that this method is not safe for multiple concurrent writers, in case of races, deployment of a machine could fail or resource might not be cleaned up.
func (AzureClient) CreateAvailabilitySetIfNotExists ¶
func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error
func (AzureClient) CreateNetworkInterface ¶
func (a AzureClient) CreateNetworkInterface(ctx *DeploymentContext, resourceGroup, name, location, publicIPAddressID, subnetID, nsgID, privateIPAddress string) error
func (AzureClient) CreateNetworkSecurityGroup ¶
func (a AzureClient) CreateNetworkSecurityGroup(ctx *DeploymentContext, resourceGroup, name, location string, rules *[]network.SecurityRule) error
func (AzureClient) CreatePublicIPAddress ¶
func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool, dnsLabel string) error
func (AzureClient) CreateResourceGroup ¶
func (a AzureClient) CreateResourceGroup(name, location string) error
CreateResourceGroup creates a Resource Group if not exists
func (AzureClient) CreateStorageAccount ¶
func (a AzureClient) CreateStorageAccount(ctx *DeploymentContext, resourceGroup, location string, storageType storage.SkuName) error
func (AzureClient) CreateSubnet ¶
func (a AzureClient) CreateSubnet(ctx *DeploymentContext, resourceGroup, virtualNetwork, name, subnetPrefix string) error
func (AzureClient) CreateVirtualMachine ¶
func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, availabilitySetID, networkInterfaceID, username, sshPublicKey, imageName, customData string, storageAccount *storage.AccountProperties) error
func (AzureClient) CreateVirtualNetworkIfNotExists ¶
func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, location string) error
func (AzureClient) DeleteNetworkInterfaceIfExists ¶
func (a AzureClient) DeleteNetworkInterfaceIfExists(resourceGroup, name string) error
func (AzureClient) DeleteNetworkSecurityGroupIfExists ¶
func (a AzureClient) DeleteNetworkSecurityGroupIfExists(resourceGroup, name string) error
func (AzureClient) DeletePublicIPAddressIfExists ¶
func (a AzureClient) DeletePublicIPAddressIfExists(resourceGroup, name string) error
func (AzureClient) DeleteVirtualMachineIfExists ¶
func (a AzureClient) DeleteVirtualMachineIfExists(resourceGroup, name string) error
func (AzureClient) GetAvailabilitySet ¶
func (a AzureClient) GetAvailabilitySet(resourceGroup, name string) (compute.AvailabilitySet, error)
func (AzureClient) GetPrivateIPAddress ¶
func (a AzureClient) GetPrivateIPAddress(resourceGroup, name string) (string, error)
GetPrivateIPAddress attempts to retrieve private IP address of the specified network interface name. If IP address is not allocated yet, returns empty string.
func (AzureClient) GetPublicIPAddress ¶
func (a AzureClient) GetPublicIPAddress(resourceGroup, name string, useFqdn bool) (string, error)
GetPublicIPAddress attempts to get public IP address from the Public IP resource. If IP address is not allocated yet, returns empty string. If useFqdn is set to true, the a FQDN hostname will be returned.
func (AzureClient) GetSubnet ¶
func (a AzureClient) GetSubnet(resourceGroup, virtualNetwork, name string) (network.Subnet, error)
func (AzureClient) GetVirtualMachinePowerState ¶
func (a AzureClient) GetVirtualMachinePowerState(resourceGroup, name string) (VMPowerState, error)
func (AzureClient) RegisterResourceProviders ¶
func (a AzureClient) RegisterResourceProviders(namespaces ...string) error
RegisterResourceProviders registers current subscription to the specified resource provider namespaces if they are not already registered. Namespaces are case-insensitive.
func (AzureClient) RestartVirtualMachine ¶
func (a AzureClient) RestartVirtualMachine(resourceGroup, name string) error
RestartVirtualMachine restarts the virtual machine and waits until it reaches the goal state (stopped) or times out.
func (AzureClient) StartVirtualMachine ¶
func (a AzureClient) StartVirtualMachine(resourceGroup, name string) error
StartVirtualMachine starts the virtual machine and waits until it reaches the goal state (running) or times out.
func (AzureClient) StopVirtualMachine ¶
func (a AzureClient) StopVirtualMachine(resourceGroup, name string) error
StopVirtualMachine power offs the virtual machine and waits until it reaches the goal state (stopped) or times out.
func (AzureClient) VirtualMachineExists ¶
func (a AzureClient) VirtualMachineExists(resourceGroup, name string) (bool, error)
type DeploymentContext ¶
type DeploymentContext struct { VirtualNetworkExists bool StorageAccount *storage.AccountProperties PublicIPAddressID string NetworkSecurityGroupID string SubnetID string NetworkInterfaceID string SSHPublicKey string AvailabilitySetID string FirewallRules *[]network.SecurityRule }
DeploymentContext contains references to various sources created and then used in creating other resources.
type ResourceNaming ¶
type ResourceNaming string
ResourceNaming provides methods to construct Azure resource names for a given machine name.
func (ResourceNaming) IP ¶
func (r ResourceNaming) IP() string
func (ResourceNaming) NIC ¶
func (r ResourceNaming) NIC() string
func (ResourceNaming) NSG ¶
func (r ResourceNaming) NSG() string
func (ResourceNaming) VM ¶
func (r ResourceNaming) VM() string
type VMPowerState ¶
type VMPowerState string
const ( // Unknown is returned when Azure does not provide a PowerState (happens // when VM is just deployed or started transitioning to another state) or // obtained PowerState is not one of the following. Unknown VMPowerState = "" // Stopped indicates that VM is allocated and in powered off state or the VM // has been just deployed for the first time. In this state, VM can be powered // on or Stopped VMPowerState = "stopped" // Stopping indicates that VM is about to go into powered off state. Stopping VMPowerState = "stopping" // Starting indicates that VM is being created or powered on. Starting VMPowerState = "starting" // Running indicates that VM is either powered on or being rebooted. VM // stays in this state during the reboot operation. In this state VM can be // stopped, restarted or deallocated. Running VMPowerState = "running" // Deallocating indicates that the VM is being terminated. Deallocating VMPowerState = "deallocating" // Deallocated indicates that the VM is being terminated. In this state, VM // can be powered on or powered off. Deallocated VMPowerState = "deallocated" )