Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAzureDataExplorerClient(metadata *DataExplorerMetadata, httpClient *http.Client) (*kusto.Client, error)
- func GetAzureAppInsightsMetricValue(ctx context.Context, info AppInsightsInfo, ...) (float64, error)
- func GetAzureBlobListLength(ctx context.Context, httpClient util.HTTPDoer, ...) (int64, error)
- func GetAzureDataExplorerMetricValue(ctx context.Context, client *kusto.Client, db string, query string) (float64, error)
- func GetAzureMetricValue(ctx context.Context, info MonitorInfo, ...) (float64, error)
- func GetAzureQueueLength(ctx context.Context, httpClient util.HTTPDoer, ...) (int64, error)
- func GetEventHubClient(ctx context.Context, info EventHubInfo) (*eventhub.Hub, error)
- func NewADWorkloadIdentityCredential(identityID string) (*azidentity.WorkloadIdentityCredential, error)
- func NewAzureADWorkloadIdentityConfig(ctx context.Context, identityID, resource string) auth.AuthorizerConfig
- func NewChainedCredential(logger logr.Logger, identityID string, ...) (*azidentity.ChainedTokenCredential, error)
- func ParseActiveDirectoryEndpoint(metadata map[string]string) (string, error)
- func ParseAzureEventHubConnectionString(connectionString string) (string, string, error)
- func ParseAzureStorageBlobConnection(ctx context.Context, httpClient util.HTTPDoer, ...) (azblob.Credential, *url.URL, error)
- func ParseAzureStorageEndpointSuffix(metadata map[string]string, endpointType StorageEndpointType) (string, error)
- func ParseAzureStorageQueueConnection(ctx context.Context, httpClient util.HTTPDoer, ...) (azqueue.Credential, *url.URL, error)
- func ParseEnvironmentProperty(metadata map[string]string, propertyKey string, ...) (string, error)
- func TryAndGetAzureManagedPrometheusHTTPRoundTripper(logger logr.Logger, podIdentity kedav1alpha1.AuthPodIdentity, ...) (http.RoundTripper, error)
- type AADToken
- type ADWorkloadIdentityConfig
- type ADWorkloadIdentityTokenProvider
- func (wiTokenProvider *ADWorkloadIdentityTokenProvider) EnsureFresh() error
- func (wiTokenProvider *ADWorkloadIdentityTokenProvider) GetToken(_ string) (*amqpAuth.Token, error)
- func (wiTokenProvider *ADWorkloadIdentityTokenProvider) OAuthToken() string
- func (wiTokenProvider *ADWorkloadIdentityTokenProvider) Refresh() error
- func (wiTokenProvider *ADWorkloadIdentityTokenProvider) RefreshExchange(resource string) error
- type AppInsightsInfo
- type ApplicationInsightsMetric
- type BlobMetadata
- type Checkpoint
- type DataExplorerMetadata
- type EnvironmentPropertyProvider
- type EventHubInfo
- type ManagedIdentityWrapper
- type MonitorInfo
- type StorageEndpointType
Constants ¶
const ( MSIURL = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=%s" MSIURLWithClientID = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=%s&client_id=%s" )
const ( DefaultCloud = "azurePublicCloud" // PrivateCloud cloud type PrivateCloud string = "Private" // Default Endpoint key in trigger metadata DefaultEndpointSuffixKey string = "endpointSuffix" // Default Storage Endpoint key in trigger metadata DefaultStorageSuffixKey string = "storageEndpointSuffix" // Default Active Directory Endpoint Key in trigger metadata DefaultActiveDirectoryEndpointKey string = "activeDirectoryEndpoint" )
const (
DefaultAppInsightsResourceURL = "https://api.applicationinsights.io"
)
const (
DefaultEventhubResourceURL = "https://eventhubs.azure.net/"
)
Variables ¶
var ( // ErrAzureConnectionStringKeyName indicates an error in the connection string AccountKey or AccountName. ErrAzureConnectionStringKeyName = errors.New("can't parse storage connection string. Missing key or name") // ErrAzureConnectionStringEndpoint indicates an error in the connection string DefaultEndpointsProtocol or EndpointSuffix. ErrAzureConnectionStringEndpoint = errors.New("can't parse storage connection string. Missing DefaultEndpointsProtocol or EndpointSuffix") )
var AppInsightsResourceURLInCloud = map[string]string{
"AZUREPUBLICCLOUD": "https://api.applicationinsights.io",
"AZUREUSGOVERNMENTCLOUD": "https://api.applicationinsights.us",
"AZURECHINACLOUD": "https://api.applicationinsights.azure.cn",
}
var AuthorityHost string
var DefaultClientID string
var TenantID string
var TokenFilePath string
Functions ¶
func CreateAzureDataExplorerClient ¶ added in v2.7.0
func GetAzureAppInsightsMetricValue ¶ added in v2.6.0
func GetAzureAppInsightsMetricValue(ctx context.Context, info AppInsightsInfo, podIdentity kedav1alpha1.AuthPodIdentity, ignoreNullValues bool) (float64, error)
GetAzureAppInsightsMetricValue returns the value of an Azure App Insights metric, rounded to the nearest int
func GetAzureBlobListLength ¶
func GetAzureBlobListLength(ctx context.Context, httpClient util.HTTPDoer, podIdentity kedav1alpha1.AuthPodIdentity, meta *BlobMetadata) (int64, error)
GetAzureBlobListLength returns the count of the blobs in blob container in int
func GetAzureDataExplorerMetricValue ¶ added in v2.7.0
func GetAzureMetricValue ¶
func GetAzureMetricValue(ctx context.Context, info MonitorInfo, podIdentity kedav1alpha1.AuthPodIdentity) (float64, error)
GetAzureMetricValue returns the value of an Azure Monitor metric, rounded to the nearest int
func GetAzureQueueLength ¶
func GetAzureQueueLength(ctx context.Context, httpClient util.HTTPDoer, podIdentity kedav1alpha1.AuthPodIdentity, connectionString, queueName, accountName, endpointSuffix string) (int64, error)
GetAzureQueueLength returns the length of a queue in int, see https://learn.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues?tabs=dotnet#get-the-queue-length
func GetEventHubClient ¶
GetEventHubClient returns eventhub client
func NewADWorkloadIdentityCredential ¶ added in v2.9.0
func NewADWorkloadIdentityCredential(identityID string) (*azidentity.WorkloadIdentityCredential, error)
func NewAzureADWorkloadIdentityConfig ¶ added in v2.8.0
func NewAzureADWorkloadIdentityConfig(ctx context.Context, identityID, resource string) auth.AuthorizerConfig
func NewChainedCredential ¶ added in v2.9.2
func NewChainedCredential(logger logr.Logger, identityID string, podIdentity v1alpha1.PodIdentityProvider) (*azidentity.ChainedTokenCredential, error)
func ParseActiveDirectoryEndpoint ¶ added in v2.7.0
func ParseAzureEventHubConnectionString ¶
ParseAzureEventHubConnectionString parses Event Hub connection string into (namespace, name) Connection string should be in following format: Endpoint=sb://eventhub-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=secretKey123;EntityPath=eventhub-name
func ParseAzureStorageBlobConnection ¶
func ParseAzureStorageBlobConnection(ctx context.Context, httpClient util.HTTPDoer, podIdentity kedav1alpha1.AuthPodIdentity, connectionString, accountName, endpointSuffix string) (azblob.Credential, *url.URL, error)
ParseAzureStorageBlobConnection parses blob connection string and returns credential and resource url
func ParseAzureStorageEndpointSuffix ¶ added in v2.4.0
func ParseAzureStorageEndpointSuffix(metadata map[string]string, endpointType StorageEndpointType) (string, error)
ParseAzureStorageEndpointSuffix parses cloud and endpointSuffix metadata and returns endpoint suffix
func ParseAzureStorageQueueConnection ¶
func ParseAzureStorageQueueConnection(ctx context.Context, httpClient util.HTTPDoer, podIdentity kedav1alpha1.AuthPodIdentity, connectionString, accountName, endpointSuffix string) (azqueue.Credential, *url.URL, error)
ParseAzureStorageQueueConnection parses queue connection string and returns credential and resource url
func ParseEnvironmentProperty ¶ added in v2.7.0
func ParseEnvironmentProperty(metadata map[string]string, propertyKey string, envPropertyProvider EnvironmentPropertyProvider) (string, error)
ParseEnvironmentProperty parses cloud metadata and returns the resolved property
func TryAndGetAzureManagedPrometheusHTTPRoundTripper ¶ added in v2.10.0
func TryAndGetAzureManagedPrometheusHTTPRoundTripper(logger logr.Logger, podIdentity kedav1alpha1.AuthPodIdentity, triggerMetadata map[string]string) (http.RoundTripper, error)
Tries to get a round tripper. If the pod identity represents azure auth, it creates a round tripper and returns that. Returns error if fails to create one. If its not azure auth, then this becomes a no-op. Neither returns round tripper nor error.
Types ¶
type AADToken ¶
type AADToken struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn string `json:"expires_in"` ExpiresOn string `json:"expires_on"` ExpiresOnTimeObject time.Time `json:"expires_on_object"` NotBefore string `json:"not_before"` Resource string `json:"resource"` TokenType string `json:"token_type"` GrantedScopes []string `json:"grantedScopes"` DeclinedScopes []string `json:"DeclinedScopes"` }
AADToken is the token from Azure AD
type ADWorkloadIdentityConfig ¶ added in v2.8.0
type ADWorkloadIdentityConfig struct { IdentityID string Resource string // contains filtered or unexported fields }
func (ADWorkloadIdentityConfig) Authorizer ¶ added in v2.8.0
func (aadWiConfig ADWorkloadIdentityConfig) Authorizer() (autorest.Authorizer, error)
Authorizer implements the auth.AuthorizerConfig interface
type ADWorkloadIdentityTokenProvider ¶ added in v2.8.0
type ADWorkloadIdentityTokenProvider struct { IdentityID string Resource string // contains filtered or unexported fields }
ADWorkloadIdentityTokenProvider is a type that implements the adal.OAuthTokenProvider and adal.Refresher interfaces. The OAuthTokenProvider interface is used by the BearerAuthorizer to get the token when preparing the HTTP Header. The Refresher interface is used by the BearerAuthorizer to refresh the token.
func NewAzureADWorkloadIdentityTokenProvider ¶ added in v2.8.0
func NewAzureADWorkloadIdentityTokenProvider(ctx context.Context, identityID, resource string) *ADWorkloadIdentityTokenProvider
func (*ADWorkloadIdentityTokenProvider) EnsureFresh ¶ added in v2.8.0
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) EnsureFresh() error
EnsureFresh is for implementing the adal.Refresher interface
func (*ADWorkloadIdentityTokenProvider) GetToken ¶ added in v2.8.0
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) GetToken(_ string) (*amqpAuth.Token, error)
GetToken is for implementing the auth.TokenProvider interface
func (*ADWorkloadIdentityTokenProvider) OAuthToken ¶ added in v2.8.0
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) OAuthToken() string
OAuthToken is for implementing the adal.OAuthTokenProvider interface. It returns the current access token.
func (*ADWorkloadIdentityTokenProvider) Refresh ¶ added in v2.8.0
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) Refresh() error
Refresh is for implementing the adal.Refresher interface
func (*ADWorkloadIdentityTokenProvider) RefreshExchange ¶ added in v2.8.0
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) RefreshExchange(resource string) error
RefreshExchange is for implementing the adal.Refresher interface
type AppInsightsInfo ¶ added in v2.6.0
type ApplicationInsightsMetric ¶ added in v2.6.0
type ApplicationInsightsMetric struct {
Value map[string]interface{}
}
type BlobMetadata ¶ added in v2.7.0
type Checkpoint ¶
type Checkpoint struct { PartitionID string `json:"PartitionId"` SequenceNumber int64 `json:"SequenceNumber"` // contains filtered or unexported fields }
Checkpoint in a common format
func GetCheckpointFromBlobStorage ¶
func GetCheckpointFromBlobStorage(ctx context.Context, httpClient util.HTTPDoer, info EventHubInfo, partitionID string) (Checkpoint, error)
GetCheckpointFromBlobStorage reads depending of the CheckpointStrategy the checkpoint from a azure storage
type DataExplorerMetadata ¶ added in v2.7.0
type EnvironmentPropertyProvider ¶ added in v2.7.0
type EnvironmentPropertyProvider func(env az.Environment) (string, error)
EnvironmentPropertyProvider for different types of Azure scalers
type EventHubInfo ¶
type EventHubInfo struct { EventHubConnection string EventHubConsumerGroup string StorageConnection string StorageAccountName string BlobStorageEndpoint string BlobContainer string Namespace string EventHubName string CheckpointStrategy string ServiceBusEndpointSuffix string ActiveDirectoryEndpoint string EventHubResourceURL string PodIdentity kedav1alpha1.AuthPodIdentity }
EventHubInfo to keep event hub connection and resources
type ManagedIdentityWrapper ¶ added in v2.9.2
type ManagedIdentityWrapper struct {
// contains filtered or unexported fields
}
func ManagedIdentityWrapperCredential ¶ added in v2.9.2
func ManagedIdentityWrapperCredential(clientID string) (*ManagedIdentityWrapper, error)
func (*ManagedIdentityWrapper) GetToken ¶ added in v2.9.2
func (w *ManagedIdentityWrapper) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error)
type MonitorInfo ¶
type MonitorInfo struct { ResourceURI string TenantID string SubscriptionID string ResourceGroupName string Name string Namespace string Filter string AggregationInterval string AggregationType string ClientID string ClientPassword string AzureResourceManagerEndpoint string ActiveDirectoryEndpoint string }
MonitorInfo to create metric request
type StorageEndpointType ¶
type StorageEndpointType int
StorageEndpointType for different types of storage provided by Azure
const ( // BlobEndpoint storage type BlobEndpoint StorageEndpointType = iota // QueueEndpoint storage type QueueEndpoint // TableEndpoint storage type TableEndpoint // FileEndpoint storage type FileEndpoint )
func (StorageEndpointType) GetEndpointSuffix ¶ added in v2.4.0
func (e StorageEndpointType) GetEndpointSuffix(environment az.Environment) string
GetEndpointSuffix returns the endpoint suffix for a StorageEndpointType based on the specified environment
func (StorageEndpointType) Name ¶
func (e StorageEndpointType) Name() string
Name returns resource name for StorageEndpointType
func (StorageEndpointType) Prefix ¶
func (e StorageEndpointType) Prefix() string
Prefix returns prefix for a StorageEndpointType
Source Files ¶
- azure_aad_auth.go
- azure_aad_podidentity.go
- azure_aad_workload_identity.go
- azure_app_insights.go
- azure_azidentity_chain.go
- azure_blob.go
- azure_cloud_environment.go
- azure_data_explorer.go
- azure_eventhub.go
- azure_eventhub_checkpoint.go
- azure_managed_prometheus_http_round_tripper.go
- azure_monitor.go
- azure_queue.go
- azure_storage.go