connection

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Azure

type Azure interface {
	IsCloudAvailable() error
	GetResourceGroupByName(name string) (resources.Group, error)
	// Storage Account Functions
	CreateStorageAccount(accountName, accountGroupName string, tags map[string]*string, httpsOnly bool, networkRuleSet *storage.NetworkRuleSet) (storage.Account, error)
	DeleteStorageAccount(resourceGroupName, accountName string) error
	//AKS Functions
	GetManagedClusterJSON(resourceGroupName, clusterName string) ([]byte, error)
	GetManagedClusterAdminCredentials(resourceGroupName, clusterName string) (string, error)
	ClusterHasRoleAssignment(resourceGroupName, clusterName, roleDefName string) (bool, error)
	//Azure Disk functions
	GetDisk(resourceGroupName string, diskName string) (d compute.Disk, err error)
	ParseDiskDetails(diskURI string) (resourceGroupName, diskName string)
	GetJSONRepresentation(resourceGroupName string, diskName string) (dskJSON []byte, err error)
}

Azure interface defining all azure methods

type AzureConnection

type AzureConnection struct {
	ResourceGroup  *AzureResourceGroup  // Client obj to interact with Azure Resource Groups
	StorageAccount *AzureStorageAccount // Client obj to interact with Azure Storage Accounts
	ManagedCluster *AzureManagedCluster // Client obj to interact with Azure Kubernetes Service
	Disk           *AzureDisk           // Client obj to interact with Azure Disks
	// contains filtered or unexported fields
}

AzureConnection simplifies the connection with cloud provider

func NewAzureConnection

func NewAzureConnection(c context.Context, subscriptionID, tenantID, clientID, clientSecret string) *AzureConnection

NewAzureConnection provides a singleton instance of AzureConnection. Initializes all internal clients to interact with Azure.

func (*AzureConnection) ClusterHasRoleAssignment

func (az *AzureConnection) ClusterHasRoleAssignment(resourceGroupName, clusterName, roleDefName string) (bool, error)

ClusterHasRoleAssignment looks through the Azure role assignments on the cluster and returns true if it find the role assigned. Note that the roleDefName is the UUID of the role not the friendly name of the role.

func (*AzureConnection) CreateStorageAccount

func (az *AzureConnection) CreateStorageAccount(accountName, accountGroupName string, tags map[string]*string, httpsOnly bool, networkRuleSet *storage.NetworkRuleSet) (storage.Account, error)

CreateStorageAccount creates a storage account

func (*AzureConnection) DeleteStorageAccount

func (az *AzureConnection) DeleteStorageAccount(resourceGroupName, accountName string) error

DeleteStorageAccount deletes a storage account

func (*AzureConnection) GetDisk

func (az *AzureConnection) GetDisk(resourceGroupName string, diskName string) (compute.Disk, error)

GetDisk returns the disk client

func (*AzureConnection) GetJSONRepresentation

func (az *AzureConnection) GetJSONRepresentation(resourceGroupName string, diskName string) (dskJSON []byte, err error)

GetJSONRepresentation returns the JSON representation of an AKS cluster, similar to az aks show. NOTE that the output from this function has differences to the az cli that needs to be accomodated if you are using the JSON created by this function.

func (*AzureConnection) GetManagedClusterAdminCredentials

func (az *AzureConnection) GetManagedClusterAdminCredentials(resourceGroupName, clusterName string) (string, error)

GetManagedClusterAdminCredentials returns a base64 encoded kubeconfig file for the cluster admin (equivalent to az get-credentials --admin)

func (*AzureConnection) GetManagedClusterJSON

func (az *AzureConnection) GetManagedClusterJSON(resourceGroupName, clusterName string) ([]byte, error)

GetManagedClusterJSON returns the JSON representation of an AKS cluster, similar to az aks show. NOTE that the output from this function has differences to the az cli that needs to be accomodated if you are using the JSON created by this function.

func (*AzureConnection) GetResourceGroupByName

func (az *AzureConnection) GetResourceGroupByName(name string) (resources.Group, error)

GetResourceGroupByName returns an existing Resource Group by name

func (*AzureConnection) IsCloudAvailable

func (az *AzureConnection) IsCloudAvailable() error

IsCloudAvailable verifies that the connection instantiation did not report a failure

func (*AzureConnection) ParseDiskDetails

func (az *AzureConnection) ParseDiskDetails(diskURI string) (string, string)

ParseDiskDetails parses the resource group name and disk name from an Azure Disk URI

type AzureCredentials

type AzureCredentials struct {
	SubscriptionID, ClientID, TenantID, ClientSecret string
	Authorizer                                       autorest.Authorizer
}

AzureCredentials ...

type AzureDisk

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

AzureDisk contains the state of the Azure Disk context

func NewDisk

func NewDisk(ctx context.Context, creds AzureCredentials) (dsk *AzureDisk, err error)

NewDisk validates the context and credentials, and retrieves the corresponding Disks Client

func (*AzureDisk) GetDisk

func (dsk *AzureDisk) GetDisk(resourceGroup string, diskName string) (d compute.Disk, err error)

GetDisk Retrieves the specified disk from the specified resource group

func (*AzureDisk) GetJSONRepresentation

func (dsk *AzureDisk) GetJSONRepresentation(resourceGroupName string, diskName string) (dskJSON []byte, err error)

GetJSONRepresentation returns the JSON representation of an AKS cluster, similar to az aks show. NOTE that the output from this function has differences to the az cli that needs to be accomodated if you are using the JSON created by this function.

func (*AzureDisk) ParseDiskDetails

func (dsk *AzureDisk) ParseDiskDetails(diskURI string) (resourceGroupName, diskName string)

ParseDiskDetails returns the resource group name and disk name of the Managed Disk

type AzureManagedCluster

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

AzureManagedCluster holds the state of the Azure context

func NewContainerService

func NewContainerService(c context.Context, creds AzureCredentials) (cs *AzureManagedCluster, err error)

NewContainerService provides a new instance of AzureContainerService

func (*AzureManagedCluster) ClusterHasRoleAssignment

func (amc *AzureManagedCluster) ClusterHasRoleAssignment(resourceGroupName, clusterName, roleDefName string) (present bool, err error)

ClusterHasRoleAssignment looks through the Azure role assignments on the cluster and returns true if it find the role assigned. Note that the roleDefName is the UUID of the role not the friendly name of the role.

func (*AzureManagedCluster) GetClusterAdminCredentials

func (amc *AzureManagedCluster) GetClusterAdminCredentials(resourceGroupName, clusterName string) (kubeconfigBase64 string, err error)

GetClusterAdminCredentials returns a base64 encoded kubeconfig file for the cluster admin (equivalent to az get-credentials --admin)

func (*AzureManagedCluster) GetJSONRepresentation

func (amc *AzureManagedCluster) GetJSONRepresentation(resourceGroupName string, clusterName string) (aksJSON []byte, err error)

GetJSONRepresentation returns the JSON representation of an AKS cluster, similar to az aks show. NOTE that the output from this function has differences to the az cli that needs to be accomodated if you are using the JSON created by this function.

type AzureResourceGroup

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

AzureResourceGroup ...

func NewResourceGroup

func NewResourceGroup(c context.Context, creds AzureCredentials) (rg *AzureResourceGroup, err error)

NewResourceGroup provides a new instance of AzureResourceGroup

func (*AzureResourceGroup) Get

func (rg *AzureResourceGroup) Get(name string) (resources.Group, error)

Get an existing Resource Group by name

type AzureStorageAccount

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

AzureStorageAccount ...

func NewStorageAccount

func NewStorageAccount(c context.Context, creds AzureCredentials) (sa *AzureStorageAccount, err error)

NewStorageAccount provides a new instance of AzureStorageAccount

func (*AzureStorageAccount) Create

func (sa *AzureStorageAccount) Create(accountName, accountGroupName string, tags map[string]*string, httpsOnly bool, networkRuleSet *storage.NetworkRuleSet) (storage.Account, error)

Create starts creation of a new Storage Account and waits for the account to be created.

func (*AzureStorageAccount) Delete

func (sa *AzureStorageAccount) Delete(resourceGroupName, accountName string) error

Delete deletes a storage account given the resource group and account name

Jump to

Keyboard shortcuts

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