azurefilebroker

package
v0.0.0-...-9e3ede1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AzureCloud        = "AzureCloud"
	AzureChinaCloud   = "AzureChinaCloud"
	AzureGermanCloud  = "AzureGermanCloud"
	AzureUSGovernment = "AzureUSGovernment"
	AzureStack        = "AzureStack"
)

Variables

View Source
var Environments = map[string]Environment{
	AzureCloud: Environment{
		ResourceManagerEndpointURL: "https://management.azure.com/",
		ActiveDirectoryEndpointURL: "https://login.microsoftonline.com",
		APIVersions: APIVersions{
			StorageForREST:  "2016-12-01",
			StorageForSDK:   "2016-05-31",
			ActiveDirectory: "2015-06-15",
		},
	},
	AzureChinaCloud: Environment{
		ResourceManagerEndpointURL: "https://management.chinacloudapi.cn/",
		ActiveDirectoryEndpointURL: "https://login.chinacloudapi.cn",
		APIVersions: APIVersions{
			StorageForREST:  "2016-12-01",
			StorageForSDK:   "2016-05-31",
			ActiveDirectory: "2015-06-15",
		},
	},
	AzureUSGovernment: Environment{
		ResourceManagerEndpointURL: "https://management.usgovcloudapi.net/",
		ActiveDirectoryEndpointURL: "https://login.microsoftonline.com",
		APIVersions: APIVersions{
			StorageForREST:  "2016-12-01",
			StorageForSDK:   "2016-05-31",
			ActiveDirectory: "2015-06-15",
		},
	},
	AzureGermanCloud: Environment{
		ResourceManagerEndpointURL: "https://management.microsoftazure.de/",
		ActiveDirectoryEndpointURL: "https://login.microsoftonline.de",
		APIVersions: APIVersions{
			StorageForREST:  "2016-12-01",
			StorageForSDK:   "2016-05-31",
			ActiveDirectory: "2015-06-15",
		},
	},
	AzureStack: Environment{
		APIVersions: APIVersions{
			StorageForREST:  "2016-12-01",
			StorageForSDK:   "2016-05-31",
			ActiveDirectory: "2015-06-15",
		},
	},
}

Functions

This section is empty.

Types

type APIVersions

type APIVersions struct {
	StorageForREST  string
	StorageForSDK   string
	ActiveDirectory string
}

type AppLock

type AppLock interface {
	GetAppLockSQL() string
	GetReleaseAppLockSQL() string
}

type AzureConfig

type AzureConfig struct {
	Environment              string
	TenanID                  string
	ClientID                 string
	ClientSecret             string
	DefaultSubscriptionID    string
	DefaultResourceGroupName string
	DefaultLocation          string
}

func NewAzureConfig

func NewAzureConfig(environment, tenanID, clientID, clientSecret, defaultSubscriptionID, defaultResourceGroupName, defaultLocation string) *AzureConfig

func (*AzureConfig) IsSupportAzureFileShare

func (config *AzureConfig) IsSupportAzureFileShare() bool

func (*AzureConfig) Validate

func (config *AzureConfig) Validate() error

type AzureRESTClient

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

func (*AzureRESTClient) CheckCompletion

func (c *AzureRESTClient) CheckCompletion(asyncURL string) (bool, error)

CheckCompletion Check whether an asynchronous operation finishes or not

func (*AzureRESTClient) CreateStorageAccount

func (c *AzureRESTClient) CreateStorageAccount() (string, error)

CreateStorageAccount Create a storage account. You need to call CheckCompletion to check whether the creation is finished. Return "", nil when the storage account has been created. Return "operation-url", nil when the storage account is still in creating. Reference: https://docs.microsoft.com/en-us/rest/api/storagerp/storageaccounts#StorageAccounts_Create

type AzureStackConfig

type AzureStackConfig struct {
	AzureStackDomain         string
	AzureStackAuthentication string
	AzureStackResource       string
	AzureStackEndpointPrefix string
}

func NewAzureStackConfig

func NewAzureStackConfig(azureStackDomain, azureStackAuthentication, azureStackResource, azureStackEndpointPrefix string) *AzureStackConfig

func (*AzureStackConfig) Validate

func (config *AzureStackConfig) Validate() error

type AzureStorageAccountRESTClient

type AzureStorageAccountRESTClient interface {
	CreateStorageAccount() (string, error)
	CheckCompletion(asyncURL string) (bool, error)
}

func NewAzureStorageAccountRESTClient

func NewAzureStorageAccountRESTClient(logger lager.Logger, cloudConfig *CloudConfig, storageAccount *StorageAccount) (AzureStorageAccountRESTClient, error)

type AzureStorageAccountSDKClient

type AzureStorageAccountSDKClient interface {
	Exists() (bool, error)
	GetAccessKey() (string, error)
	DeleteStorageAccount() error
	HasFileShare(fileShareName string) (bool, error)
	CreateFileShare(fileShareName string) error
	DeleteFileShare(fileShareName string) error
	GetShareURL(fileShareName string) (string, error)
}

func NewAzureStorageAccountSDKClient

func NewAzureStorageAccountSDKClient(logger lager.Logger, cloudConfig *CloudConfig, storageAccount *StorageAccount) (AzureStorageAccountSDKClient, error)

type AzureStorageSDKClient

type AzureStorageSDKClient struct {
	StorageAccount *StorageAccount
	// contains filtered or unexported fields
}

func (*AzureStorageSDKClient) CreateFileShare

func (c *AzureStorageSDKClient) CreateFileShare(fileShareName string) error

func (*AzureStorageSDKClient) DeleteFileShare

func (c *AzureStorageSDKClient) DeleteFileShare(fileShareName string) error

func (*AzureStorageSDKClient) DeleteStorageAccount

func (c *AzureStorageSDKClient) DeleteStorageAccount() error

func (*AzureStorageSDKClient) Exists

func (c *AzureStorageSDKClient) Exists() (bool, error)

func (*AzureStorageSDKClient) GetAccessKey

func (c *AzureStorageSDKClient) GetAccessKey() (string, error)

func (*AzureStorageSDKClient) GetShareURL

func (c *AzureStorageSDKClient) GetShareURL(fileShareName string) (string, error)

func (*AzureStorageSDKClient) HasFileShare

func (c *AzureStorageSDKClient) HasFileShare(fileShareName string) (bool, error)

type AzureToken

type AzureToken struct {
	ExpiresOn   time.Time
	AccessToken string
}

type BindOptions

type BindOptions struct {
	UID           string `json:"uid"`
	GID           string `json:"gid"`
	FileMode      string `json:"file_mode"`
	DirMode       string `json:"dir_mode"`
	Readonly      bool   `json:"readonly"`
	Mount         string `json:"mount"`
	Vers          string `json:"vers"`     // Required for AzureFileShare
	FileShareName string `json:"share"`    // Required for AzureFileShare
	Domain        string `json:"domain"`   // Optional for preexisting shares
	Username      string `json:"username"` // Required for preexisting shares
	Password      string `json:"password"` // Optional for preexisting shares
	Sec           string `json:"sec"`      // Optional for preexisting shares
}

func (BindOptions) ToMap

func (options BindOptions) ToMap() map[string]string

ToMap Omit Mount, FileShareName, Domain, Username and Password

func (BindOptions) Validate

func (options BindOptions) Validate(isPreexisting bool) error

type Broker

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

func New

func New(
	logger lager.Logger,
	serviceName, serviceID string,
	clock clock.Clock,
	store Store,
	config *Config,
) *Broker

func (*Broker) Bind

func (b *Broker) Bind(context context.Context, instanceID string, bindingID string, details brokerapi.BindDetails) (_ brokerapi.Binding, e error)

func (*Broker) Deprovision

func (b *Broker) Deprovision(context context.Context, instanceID string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (_ brokerapi.DeprovisionServiceSpec, e error)

func (*Broker) LastOperation

func (b *Broker) LastOperation(_ context.Context, instanceID string, operationData string) (brokerapi.LastOperation, error)

func (*Broker) Provision

func (b *Broker) Provision(context context.Context, instanceID string, details brokerapi.ProvisionDetails, asyncAllowed bool) (_ brokerapi.ProvisionedServiceSpec, e error)

Provision Create a service instance which is mapped to a storage account or preexisting shares For AzureFileShare: UseHTTPS must be set to false. Otherwise, the mount in Linux will fail. https://docs.microsoft.com/en-us/azure/storage/storage-security-guide

func (*Broker) Services

func (b *Broker) Services(_ context.Context) ([]brokerapi.Service, error)

func (*Broker) Unbind

func (b *Broker) Unbind(context context.Context, instanceID string, bindingID string, details brokerapi.UnbindDetails) (e error)

func (*Broker) Update

func (b *Broker) Update(context context.Context, instanceID string, details brokerapi.UpdateDetails, asyncAllowed bool) (brokerapi.UpdateServiceSpec, error)

type CloudConfig

type CloudConfig struct {
	Azure      AzureConfig
	Control    ControlConfig
	AzureStack AzureStackConfig
}

func NewAzurefilebrokerCloudConfig

func NewAzurefilebrokerCloudConfig(azure *AzureConfig, control *ControlConfig, azureStack *AzureStackConfig) *CloudConfig

func (*CloudConfig) Validate

func (config *CloudConfig) Validate() error

type Config

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

func NewAzurefilebrokerConfig

func NewAzurefilebrokerConfig(mountConfig *MountConfig, cloudConfig *CloudConfig) *Config

type Configuration

type Configuration struct {
	SubscriptionID     string `json:"subscription_id"`
	ResourceGroupName  string `json:"resource_group_name"`
	StorageAccountName string `json:"storage_account_name"` // Required for AzureFileShare
	Location           string `json:"location"`
	UseHTTPS           string `json:"use_https"` // bool
	SkuName            string `json:"sku_name"`
	CustomDomainName   string `json:"custom_domain_name"`
	UseSubDomain       string `json:"use_sub_domain"`    // bool
	EnableEncryption   string `json:"enable_encryption"` // bool
	Share              string `json:"share"`             // Required for preexisting shares
}

TBD: custom_domain_name and use_sub_domain are not supported now.

func (*Configuration) ValidateForAzureFileShare

func (config *Configuration) ValidateForAzureFileShare() error

type ControlConfig

type ControlConfig struct {
	AllowCreateStorageAccount bool
	AllowCreateFileShare      bool
	AllowDeleteStorageAccount bool
	AllowDeleteFileShare      bool
}

func NewControlConfig

func NewControlConfig(allowCreateStorageAccount, allowCreateFileShare, allowDeleteStorageAccount, allowDeleteFileShare bool) *ControlConfig

type DBInitialize

type DBInitialize interface {
	GetInitializeDatabaseSQL() []string
}

type Environment

type Environment struct {
	ResourceManagerEndpointURL string
	ActiveDirectoryEndpointURL string
	APIVersions                APIVersions
}

type FileShare

type FileShare struct {
	InstanceID      string `json:"instance_id"`
	FileShareName   string `json:"file_share_name"`
	IsCreated       bool   `json:"is_created"` // true if it is created by the broker.
	Count           int    `json:"count"`
	URL             string `json:"url"`
	DatabaseVersion string `json:"database_version"`
}

type MountConfig

type MountConfig struct {
	Allowed []string

	Forced  map[string]string
	Options map[string]string
}

func NewAzurefilebrokerMountConfig

func NewAzurefilebrokerMountConfig() *MountConfig

func (*MountConfig) Copy

func (config *MountConfig) Copy() *MountConfig

func (MountConfig) MakeConfig

func (config MountConfig) MakeConfig() map[string]interface{}

func (*MountConfig) ReadConf

func (config *MountConfig) ReadConf(allowedFlag string, defaultFlag string) error

func (*MountConfig) SetEntries

func (config *MountConfig) SetEntries(opts map[string]string) error

type ServiceInstance

type ServiceInstance struct {
	ServiceID               string `json:"service_id"`
	PlanID                  string `json:"plan_id"`
	OrganizationGUID        string `json:"organization_guid"`
	SpaceGUID               string `json:"space_guid"`
	TargetName              string `json:"target_name"`    // AzureFileShare: StorageAccountName; Preexisting shares: Share URL
	IsPreexisting           bool   `json:"is_preexisting"` // True when preexisting shares are used; False when AzureFileShare is used.
	SubscriptionID          string `json:"subscription_id"`
	ResourceGroupName       string `json:"resource_group_name"`
	UseHTTPS                string `json:"use_https"`
	IsCreatedStorageAccount bool   `json:"is_created_storage_account"`
	OperationURL            string `json:"operation_url"`
	DatabaseVersion         string `json:"database_version"`
}

type SqlConnection

type SqlConnection interface {
	Connect() error
	sqlshim.SqlDB

	DBInitialize
	AppLock
}

func NewSqlConnection

func NewSqlConnection(variant SqlVariant) SqlConnection

type SqlStore

type SqlStore struct {
	StoreType string
	Database  SqlConnection
}

func (*SqlStore) CreateBindingDetails

func (s *SqlStore) CreateBindingDetails(id string, details brokerapi.BindDetails, redactRawParameter bool) error

func (*SqlStore) CreateFileShare

func (s *SqlStore) CreateFileShare(id string, share FileShare) error

func (*SqlStore) CreateServiceInstance

func (s *SqlStore) CreateServiceInstance(id string, instance ServiceInstance) error

func (*SqlStore) DeleteBindingDetails

func (s *SqlStore) DeleteBindingDetails(id string) error

func (*SqlStore) DeleteFileShare

func (s *SqlStore) DeleteFileShare(id string) error

func (*SqlStore) DeleteServiceInstance

func (s *SqlStore) DeleteServiceInstance(id string) error

func (*SqlStore) GetLockForUpdate

func (s *SqlStore) GetLockForUpdate(lockName string, seconds int) error

func (*SqlStore) ReleaseLockForUpdate

func (s *SqlStore) ReleaseLockForUpdate(lockName string) error

func (*SqlStore) RetrieveBindingDetails

func (s *SqlStore) RetrieveBindingDetails(id string) (brokerapi.BindDetails, error)

func (*SqlStore) RetrieveFileShare

func (s *SqlStore) RetrieveFileShare(id string) (FileShare, error)

func (*SqlStore) RetrieveServiceInstance

func (s *SqlStore) RetrieveServiceInstance(id string) (ServiceInstance, error)

func (*SqlStore) UpdateFileShare

func (s *SqlStore) UpdateFileShare(id string, share FileShare) error

type SqlVariant

type SqlVariant interface {
	Connect() (sqlshim.SqlDB, error)

	DBInitialize
	AppLock
}

func NewMSSqlVariant

func NewMSSqlVariant(logger lager.Logger, username, password, host, port, dbName, caCert, hostNameInCertificate string) SqlVariant

func NewMSSqlVariantWithShims

func NewMSSqlVariantWithShims(logger lager.Logger, username, password, host, port, dbName, caCert, hostNameInCertificate string, sql sqlshim.Sql) SqlVariant

func NewMySqlVariant

func NewMySqlVariant(logger lager.Logger, username, password, host, port, dbName, caCert, hostNameInCertificate string) SqlVariant

func NewMySqlVariantWithSqlObject

func NewMySqlVariantWithSqlObject(logger lager.Logger, username, password, host, port, dbName, caCert, hostNameInCertificate string, sql sqlshim.Sql) SqlVariant

type StorageAccount

type StorageAccount struct {
	SubscriptionID          string
	ResourceGroupName       string
	StorageAccountName      string
	UseHTTPS                bool
	EnableEncryption        bool
	SkuName                 storage.SkuName
	Location                string
	IsCreatedStorageAccount bool
	AccessKey               string
	BaseURL                 string
	OperationURL            string
	SDKClient               AzureStorageAccountSDKClient
}

func NewStorageAccount

func NewStorageAccount(logger lager.Logger, configuration Configuration) (*StorageAccount, error)

type Store

type Store interface {
	RetrieveServiceInstance(id string) (ServiceInstance, error)
	RetrieveBindingDetails(id string) (brokerapi.BindDetails, error)
	RetrieveFileShare(id string) (FileShare, error)

	CreateServiceInstance(id string, instance ServiceInstance) error
	CreateBindingDetails(id string, details brokerapi.BindDetails, redactRawParameter bool) error
	CreateFileShare(id string, share FileShare) error

	UpdateFileShare(id string, share FileShare) error

	DeleteServiceInstance(id string) error
	DeleteBindingDetails(id string) error
	DeleteFileShare(id string) error

	GetLockForUpdate(lockName string, timeoutInSeconds int) error
	ReleaseLockForUpdate(lockName string) error
}

func NewStore

func NewStore(logger lager.Logger, dbDriver, dbUsername, dbPassword, dbHostname, dbPort, dbName, dbCACert, hostNameInCertificate string) Store

func NewStoreWithVariant

func NewStoreWithVariant(logger lager.Logger, storeType string, toDatabase SqlVariant) (Store, error)

Jump to

Keyboard shortcuts

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