mirror of
https://github.com/grafana/grafana.git
synced 2025-09-28 17:44:32 +08:00

* Update Azure Monitor * Update Prometheus * Update README * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * README updates * Fix prettier * memoize options --------- Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { SelectableValue } from '@grafana/data';
|
|
|
|
export enum AzureCloud {
|
|
Public = 'AzureCloud',
|
|
China = 'AzureChinaCloud',
|
|
USGovernment = 'AzureUSGovernment',
|
|
None = '',
|
|
}
|
|
|
|
export const KnownAzureClouds: Array<SelectableValue<AzureCloud>> = [
|
|
{ value: AzureCloud.Public, label: 'Azure' },
|
|
{ value: AzureCloud.China, label: 'Azure China' },
|
|
{ value: AzureCloud.USGovernment, label: 'Azure US Government' },
|
|
];
|
|
|
|
export type AzureAuthType = 'msi' | 'clientsecret' | 'workloadidentity';
|
|
|
|
export type ConcealedSecret = symbol;
|
|
|
|
interface AzureCredentialsBase {
|
|
authType: AzureAuthType;
|
|
defaultSubscriptionId?: string;
|
|
}
|
|
|
|
export interface AzureManagedIdentityCredentials extends AzureCredentialsBase {
|
|
authType: 'msi';
|
|
}
|
|
|
|
export interface AzureWorkloadIdentityCredentials extends AzureCredentialsBase {
|
|
authType: 'workloadidentity';
|
|
}
|
|
|
|
export interface AzureClientSecretCredentials extends AzureCredentialsBase {
|
|
authType: 'clientsecret';
|
|
azureCloud?: string;
|
|
tenantId?: string;
|
|
clientId?: string;
|
|
clientSecret?: string | ConcealedSecret;
|
|
}
|
|
|
|
export type AzureCredentials =
|
|
| AzureManagedIdentityCredentials
|
|
| AzureClientSecretCredentials
|
|
| AzureWorkloadIdentityCredentials;
|
|
|
|
export function isCredentialsComplete(credentials: AzureCredentials): boolean {
|
|
switch (credentials.authType) {
|
|
case 'msi':
|
|
case 'workloadidentity':
|
|
return true;
|
|
case 'clientsecret':
|
|
return !!(credentials.azureCloud && credentials.tenantId && credentials.clientId && credentials.clientSecret);
|
|
}
|
|
}
|