Documentation
¶
Index ¶
- Constants
- func EnsureVHDExtension(s string) string
- func RandomStorageAccountName(prefix string) string
- type AccountsClient
- type BlobMetadata
- type Client
- func (ac Client) CreateStorageAccount(ctx context.Context, resourceGroup, name, location string, tag Tag) error
- func (ac Client) CreateVM(ctx context.Context, resourceGroup, image, name, size, username, sshKey string) (*VM, error)
- func (ac Client) DeleteImage(ctx context.Context, resourceGroup, imageName string) error
- func (ac Client) DestroyVM(ctx context.Context, vm *VM) error
- func (ac Client) GetResourceGroupLocation(ctx context.Context, resourceGroup string) (string, error)
- func (ac Client) GetResourceNameByTag(ctx context.Context, resourceGroup string, tag Tag) (string, error)
- func (ac Client) GetStorageAccountKey(ctx context.Context, resourceGroup string, storageAccount string) (string, error)
- func (ac Client) RegisterImage(ctx context.Context, ...) error
- type Credentials
- type DisksClient
- type HyperVGenerationType
- type ImagesClient
- type InterfacesClient
- type PublicIPsClient
- type ResourceGroupsClient
- type ResourcesClient
- type SecurityGroupsClient
- type StorageClient
- func (c StorageClient) CreateStorageContainerIfNotExist(ctx context.Context, storageAccount, name string) error
- func (c StorageClient) DeleteBlob(ctx context.Context, metadata BlobMetadata) error
- func (c StorageClient) TagBlob(ctx context.Context, metadata BlobMetadata, tags map[string]string) error
- func (c StorageClient) UploadPageBlob(metadata BlobMetadata, fileName string, threads int) error
- type SubnetsClient
- type Tag
- type VM
- type VMsClient
- type VirtualNetworksClient
Constants ¶
const DefaultUploadThreads = 16
DefaultUploadThreads defines a tested default value for the UploadPageBlob method's threads parameter.
const PageBlobMaxUploadPagesBytes = 4 * datasizes.MiB
PageBlobMaxUploadPagesBytes defines how much bytes can we upload in a single UploadPages call. See https://learn.microsoft.com/en-us/rest/api/storageservices/put-page
Variables ¶
This section is empty.
Functions ¶
func EnsureVHDExtension ¶
EnsureVHDExtension returns the given string with .vhd suffix if it already doesn't have one.
func RandomStorageAccountName ¶
RandomStorageAccountName returns a randomly generated name that can be used for a storage account. This means that it must use only alphanumeric characters and its length must be 24 or lower.
Types ¶
type AccountsClient ¶
type AccountsClient interface {
BeginCreate(context.Context, string, string, armstorage.AccountCreateParameters, *armstorage.AccountsClientBeginCreateOptions) (*runtime.Poller[armstorage.AccountsClientCreateResponse], error)
ListKeys(context.Context, string, string, *armstorage.AccountsClientListKeysOptions) (armstorage.AccountsClientListKeysResponse, error)
}
type BlobMetadata ¶
BlobMetadata contains information needed to store the image in a proper place. In case of Azure cloud storage this includes container name and blob name.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(credentials Credentials, tenantID, subscriptionID string) (*Client, error)
NewClient creates a client for accessing the Azure API. See https://docs.microsoft.com/en-us/rest/api/azure/ If you need to work with the Azure Storage API, see NewStorageClient
func (Client) CreateStorageAccount ¶
func (ac Client) CreateStorageAccount(ctx context.Context, resourceGroup, name, location string, tag Tag) error
CreateStorageAccount creates a storage account in the specified resource group. The location parameter can be used to specify its location. The tag can be used to specify a tag attached to the account. The location is optional and if not provided, it is determined from the resource group.
func (Client) DeleteImage ¶ added in v0.181.0
func (Client) GetResourceGroupLocation ¶
func (ac Client) GetResourceGroupLocation(ctx context.Context, resourceGroup string) (string, error)
GetResourceGroupLocation returns the location of the given resource group.
func (Client) GetResourceNameByTag ¶
func (ac Client) GetResourceNameByTag(ctx context.Context, resourceGroup string, tag Tag) (string, error)
GetResourceNameByTag returns a name of an Azure resource tagged with the given `tag`. Note that if multiple resources with the same tag exists in the specified resource group, only one name is returned. It's undefined which one it is.
func (Client) GetStorageAccountKey ¶
func (ac Client) GetStorageAccountKey(ctx context.Context, resourceGroup string, storageAccount string) (string, error)
GetStorageAccountKey returns a storage account key that can be used to access the given storage account. This method always returns only the first key.
func (Client) RegisterImage ¶
func (ac Client) RegisterImage(ctx context.Context, resourceGroup, storageAccount, storageContainer, blobName, imageName, location string, hyperVGen HyperVGenerationType) error
RegisterImage creates a generalized V1 Linux image from a given blob. The location is optional and if not provided, it is determined from the resource group.
type Credentials ¶
func ParseAzureCredentialsFile ¶
func ParseAzureCredentialsFile(filename string) (*Credentials, error)
ParseAzureCredentialsFile parses a credentials file for azure. The file is in toml format and contains two keys: client_id and client_secret
Example of the file: client_id = "clientIdOfMyApplication" client_secret = "ToucanToucan~"
type DisksClient ¶ added in v0.181.0
type DisksClient interface {
BeginDelete(context.Context, string, string, *armcompute.DisksClientBeginDeleteOptions) (*runtime.Poller[armcompute.DisksClientDeleteResponse], error)
}
type HyperVGenerationType ¶
type HyperVGenerationType string
const ( HyperVGenV1 HyperVGenerationType = "V1" HyperVGenV2 HyperVGenerationType = "V2" )
type ImagesClient ¶
type ImagesClient interface {
BeginCreateOrUpdate(context.Context, string, string, armcompute.Image, *armcompute.ImagesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.ImagesClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armcompute.ImagesClientBeginDeleteOptions) (*runtime.Poller[armcompute.ImagesClientDeleteResponse], error)
}
type InterfacesClient ¶ added in v0.181.0
type InterfacesClient interface {
BeginCreateOrUpdate(context.Context, string, string, armnetwork.Interface, *armnetwork.InterfacesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.InterfacesClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armnetwork.InterfacesClientBeginDeleteOptions) (*runtime.Poller[armnetwork.InterfacesClientDeleteResponse], error)
}
type PublicIPsClient ¶ added in v0.181.0
type PublicIPsClient interface {
BeginCreateOrUpdate(context.Context, string, string, armnetwork.PublicIPAddress, *armnetwork.PublicIPAddressesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.PublicIPAddressesClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armnetwork.PublicIPAddressesClientBeginDeleteOptions) (*runtime.Poller[armnetwork.PublicIPAddressesClientDeleteResponse], error)
}
type ResourceGroupsClient ¶
type ResourceGroupsClient interface {
Get(context.Context, string, *armresources.ResourceGroupsClientGetOptions) (armresources.ResourceGroupsClientGetResponse, error)
}
type ResourcesClient ¶
type ResourcesClient interface {
NewListByResourceGroupPager(string, *armresources.ClientListByResourceGroupOptions) *runtime.Pager[armresources.ClientListByResourceGroupResponse]
}
type SecurityGroupsClient ¶ added in v0.181.0
type SecurityGroupsClient interface {
BeginCreateOrUpdate(context.Context, string, string, armnetwork.SecurityGroup, *armnetwork.SecurityGroupsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.SecurityGroupsClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armnetwork.SecurityGroupsClientBeginDeleteOptions) (*runtime.Poller[armnetwork.SecurityGroupsClientDeleteResponse], error)
}
type StorageClient ¶
type StorageClient struct {
// contains filtered or unexported fields
}
StorageClient is a client for the Azure Storage API, see the docs: https://docs.microsoft.com/en-us/rest/api/storageservices/
func NewStorageClient ¶
func NewStorageClient(storageAccount, storageAccessKey string) (*StorageClient, error)
NewStorageClient creates a new client for Azure Storage API. See the following keys how to retrieve the storageAccessKey using the Azure's API: https://docs.microsoft.com/en-us/rest/api/storagerp/storageaccounts/listkeys
func (StorageClient) CreateStorageContainerIfNotExist ¶
func (c StorageClient) CreateStorageContainerIfNotExist(ctx context.Context, storageAccount, name string) error
CreateStorageContainerIfNotExist creates an empty storage container inside a storage account. If a container with the same name already exists, this method is no-op.
func (StorageClient) DeleteBlob ¶ added in v0.181.0
func (c StorageClient) DeleteBlob(ctx context.Context, metadata BlobMetadata) error
func (StorageClient) TagBlob ¶
func (c StorageClient) TagBlob(ctx context.Context, metadata BlobMetadata, tags map[string]string) error
func (StorageClient) UploadPageBlob ¶
func (c StorageClient) UploadPageBlob(metadata BlobMetadata, fileName string, threads int) error
UploadPageBlob takes the metadata and credentials required to upload the image specified by `fileName` It can speed up the upload by using goroutines. The number of parallel goroutines is bounded by the `threads` argument.
Note that if you want to create an image out of the page blob, make sure that metadata.BlobName has a .vhd extension, see EnsureVHDExtension.
type SubnetsClient ¶ added in v0.181.0
type SubnetsClient interface {
BeginCreateOrUpdate(context.Context, string, string, string, armnetwork.Subnet, *armnetwork.SubnetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.SubnetsClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, string, *armnetwork.SubnetsClientBeginDeleteOptions) (*runtime.Poller[armnetwork.SubnetsClientDeleteResponse], error)
}
type VMsClient ¶ added in v0.181.0
type VMsClient interface {
BeginCreateOrUpdate(context.Context, string, string, armcompute.VirtualMachine, *armcompute.VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armcompute.VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[armcompute.VirtualMachinesClientDeleteResponse], error)
}
type VirtualNetworksClient ¶ added in v0.181.0
type VirtualNetworksClient interface {
BeginCreateOrUpdate(context.Context, string, string, armnetwork.VirtualNetwork, *armnetwork.VirtualNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.VirtualNetworksClientCreateOrUpdateResponse], error)
BeginDelete(context.Context, string, string, *armnetwork.VirtualNetworksClientBeginDeleteOptions) (*runtime.Poller[armnetwork.VirtualNetworksClientDeleteResponse], error)
}