azure

package
v0.0.0-...-778623d Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

TODO: Switch to using the latest azure sdk and remove nolint. Related Ticket- https://github.com/kanisterio/kanister/issues/168

Index

Constants

View Source
const ActiveDirectory = "activeDirectory"
View Source
const (
	// NotAvailable is used for endpoints and resource IDs that are not available for a given cloud.
	NotAvailable = "N/A"
)

Variables

View Source
var (
	// PublicCloud is the default public Azure cloud environment
	//Ref: https://github.com/Azure/azure-sdk-for-go/blob/sdk/storage/azblob/v0.4.0/eng/common/TestResources/clouds/AzureCloud.json
	PublicCloud = Environment{
		Name:                    "AzurePublicCloud",
		ResourceManagerEndpoint: "https://management.azure.com/",
		ActiveDirectoryEndpoint: "https://login.microsoftonline.com/",
		StorageEndpointSuffix:   "core.windows.net",
		Configuration:           cloud.AzurePublic,
	}

	// USGovernmentCloud is the cloud environment for the US Government
	//Ref: https://github.com/Azure/azure-sdk-for-go/blob/sdk/storage/azblob/v0.4.0/eng/common/TestResources/clouds/AzureUSGovernment.json
	USGovernmentCloud = Environment{
		Name:                    "AzureUSGovernmentCloud",
		ResourceManagerEndpoint: "https://management.usgovcloudapi.net/",
		ActiveDirectoryEndpoint: "https://login.microsoftonline.us/",
		StorageEndpointSuffix:   "core.usgovcloudapi.net",
		Configuration:           cloud.AzureGovernment,
	}

	// ChinaCloud is the cloud environment operated in China
	//Ref: https://github.com/Azure/azure-sdk-for-go/blob/sdk/storage/azblob/v0.4.0/eng/common/TestResources/clouds/AzureChinaCloud.json
	ChinaCloud = Environment{
		Name:                    "AzureChinaCloud",
		ResourceManagerEndpoint: "https://management.chinacloudapi.cn/",
		ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/",
		StorageEndpointSuffix:   "core.chinacloudapi.cn",
		Configuration:           cloud.AzureChina,
	}

	// GermanCloud is the cloud environment operated in Germany has been deprecated
	// Ref: https://learn.microsoft.com/en-us/previous-versions/azure/germany/germany-welcome
	GermanCloud = Environment{
		Name:                    "AzureGermanCloud",
		ResourceManagerEndpoint: NotAvailable,
		ActiveDirectoryEndpoint: NotAvailable,
		StorageEndpointSuffix:   NotAvailable,
		Configuration:           cloud.Configuration{},
	}
)

Functions

func NewProvider

func NewProvider(ctx context.Context, config map[string]string) (blockstorage.Provider, error)

NewProvider returns a provider for the Azure blockstorage type

Types

type AdStorage

type AdStorage struct {
	// contains filtered or unexported fields
}

AdStorage describes the azure storage client

func (*AdStorage) FromRegion

func (s *AdStorage) FromRegion(ctx context.Context, region string) ([]string, error)

func (*AdStorage) GetRegions

func (s *AdStorage) GetRegions(ctx context.Context) ([]string, error)

func (*AdStorage) SetTags

func (s *AdStorage) SetTags(ctx context.Context, resource interface{}, tags map[string]string) error

func (*AdStorage) SnapshotCopy

func (*AdStorage) SnapshotCopyWithArgs

func (s *AdStorage) SnapshotCopyWithArgs(ctx context.Context, from blockstorage.Snapshot,
	to blockstorage.Snapshot, args map[string]string) (*blockstorage.Snapshot, error)

SnapshotCopyWithArgs func: args map should contain non-empty StorageAccountName(AZURE_MIGRATE_STORAGE_ACCOUNT_NAME) and StorageKey(AZURE_MIGRATE_STORAGE_ACCOUNT_KEY) A destination ResourceGroup (AZURE_MIGRATE_RESOURCE_GROUP) can be provided. The created snapshot will belong to this.

func (*AdStorage) SnapshotCreate

func (s *AdStorage) SnapshotCreate(ctx context.Context, volume blockstorage.Volume, tags map[string]string) (*blockstorage.Snapshot, error)

func (*AdStorage) SnapshotCreateWaitForCompletion

func (s *AdStorage) SnapshotCreateWaitForCompletion(ctx context.Context, snap *blockstorage.Snapshot) error

func (*AdStorage) SnapshotDelete

func (s *AdStorage) SnapshotDelete(ctx context.Context, snapshot *blockstorage.Snapshot) error

func (*AdStorage) SnapshotGet

func (s *AdStorage) SnapshotGet(ctx context.Context, id string) (*blockstorage.Snapshot, error)

func (*AdStorage) SnapshotParse

func (s *AdStorage) SnapshotParse(ctx context.Context, snapshot interface{}) (*blockstorage.Snapshot, error)

func (*AdStorage) SnapshotRestoreTargets

func (s *AdStorage) SnapshotRestoreTargets(ctx context.Context, snapshot *blockstorage.Snapshot) (global bool, regionsAndZones map[string][]string, err error)

func (*AdStorage) SnapshotsList

func (s *AdStorage) SnapshotsList(ctx context.Context, tags map[string]string) ([]*blockstorage.Snapshot, error)

func (*AdStorage) Type

func (s *AdStorage) Type() blockstorage.Type

func (*AdStorage) VolumeCreate

func (s *AdStorage) VolumeCreate(ctx context.Context, volume blockstorage.Volume) (*blockstorage.Volume, error)

func (*AdStorage) VolumeCreateFromSnapshot

func (s *AdStorage) VolumeCreateFromSnapshot(ctx context.Context, snapshot blockstorage.Snapshot, tags map[string]string) (*blockstorage.Volume, error)

func (*AdStorage) VolumeDelete

func (s *AdStorage) VolumeDelete(ctx context.Context, volume *blockstorage.Volume) error

func (*AdStorage) VolumeGet

func (s *AdStorage) VolumeGet(ctx context.Context, id string, zone string) (*blockstorage.Volume, error)

func (*AdStorage) VolumeParse

func (s *AdStorage) VolumeParse(ctx context.Context, volume interface{}) (*blockstorage.Volume, error)

func (*AdStorage) VolumesList

func (s *AdStorage) VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*blockstorage.Volume, error)

type AzureAuthenticator

type AzureAuthenticator interface {
	Authenticate(creds map[string]string) error
	GetAuthorizer() azcore.TokenCredential
}

Public interface to authenticate with different Azure credentials type

func NewAzureAuthenticator

func NewAzureAuthenticator(config map[string]string) (AzureAuthenticator, error)

type Client

type Client struct {
	Cred                azcore.TokenCredential
	SubscriptionID      string
	ResourceGroup       string
	BaseURI             string
	DisksClient         *armcompute.DisksClient
	SnapshotsClient     *armcompute.SnapshotsClient
	SKUsClient          *armcompute.ResourceSKUsClient
	SubscriptionsClient *armsubscriptions.Client
}

Client is a wrapper

func NewClient

func NewClient(ctx context.Context, config map[string]string) (*Client, error)

type ClientCredentialsConfig

type ClientCredentialsConfig struct {
	ClientID     string
	ClientSecret string
	TenantID     string
	AuxTenants   []string
	AADEndpoint  string
	Resource     string
}

func NewClientCredentialsConfig

func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string) ClientCredentialsConfig

Defaults to Public Cloud and Resource Manager Endpoint.

type ClientSecretAuthenticator

type ClientSecretAuthenticator struct {
	azcore.TokenCredential
}

authenticate with client secret creds

func (*ClientSecretAuthenticator) Authenticate

func (c *ClientSecretAuthenticator) Authenticate(creds map[string]string) error

func (*ClientSecretAuthenticator) GetAuthorizer

type Environment

type Environment struct {
	Name                    string `json:"name"`
	ResourceManagerEndpoint string `json:"resourceManagerEndpoint"`
	ActiveDirectoryEndpoint string `json:"activeDirectoryEndpoint"`
	StorageEndpointSuffix   string `json:"storageEndpointSuffix"`
	Configuration           cloud.Configuration
}

Environment represents a set of endpoints for each of Azure's Clouds.

func EnvironmentFromName

func EnvironmentFromName(name string) (Environment, error)

EnvironmentFromName returns an Environment based on the common name specified.

type IPAddress

type IPAddress struct {
	PrivateIP string `json:"privateIPAddress"`
	PublicIP  string `json:"publicIPAddress"`
}

IPAddress represents IP address information.

type InstanceMetadata

type InstanceMetadata struct {
	// contains filtered or unexported fields
}

InstanceMetadata knows how to query the Azure instance metadata server.

func NewInstanceMetadata

func NewInstanceMetadata() *InstanceMetadata

NewInstanceMetadata creates an instance of the InstanceMetadata accessor object.

func (*InstanceMetadata) Object

func (i *InstanceMetadata) Object(path string, obj interface{}) error

Object queries the metadata server and populates the passed in object

func (*InstanceMetadata) Text

func (i *InstanceMetadata) Text(path string) (string, error)

Text queries the metadata server and returns the corresponding text

type LocationZoneMap

type LocationZoneMap map[string]struct{}

type MsiAuthenticator

type MsiAuthenticator struct {
	azcore.TokenCredential
}

authenticate with MSI creds

func (*MsiAuthenticator) Authenticate

func (m *MsiAuthenticator) Authenticate(config map[string]string) error

func (*MsiAuthenticator) GetAuthorizer

func (m *MsiAuthenticator) GetAuthorizer() azcore.TokenCredential

type NetworkData

type NetworkData struct {
	IPAddress []IPAddress `json:"ipAddress"`
	Subnet    []Subnet    `json:"subnet"`
}

NetworkData contains IP information for a network.

type NetworkInterface

type NetworkInterface struct {
	IPV4 NetworkData `json:"ipv4"`
	IPV6 NetworkData `json:"ipv6"`
	MAC  string      `json:"macAddress"`
}

NetworkInterface represents an instances network interface.

type NetworkMetadata

type NetworkMetadata struct {
	Interface []NetworkInterface `json:"interface"`
}

NetworkMetadata contains metadata about an instance's network

type Subnet

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

Subnet represents subnet information.

Jump to

Keyboard shortcuts

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