Prometheus: Fix config bug for sigv4 auth (#76390)

fix config bug for selecting sigv4
This commit is contained in:
Brendan O'Handley 2023-10-12 12:46:49 -04:00 committed by GitHub
parent 9d8be05cce
commit 67e3e576d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { DataSourceSettings } from '@grafana/data';
import { Auth, ConnectionSettings, convertLegacyAuthProps } from '@grafana/experimental';
import { Auth, ConnectionSettings, convertLegacyAuthProps, AuthMethod } from '@grafana/experimental';
import { SecureSocksProxySettings, useTheme2 } from '@grafana/ui';
import { AzureAuthSettings } from '@grafana/ui/src/components/DataSourceSettings/types';
@ -127,21 +127,12 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
/>
<hr className={`${styles.hrTopSpace} ${styles.hrBottomSpace}`} />
<Auth
// Reshaped legacy props
{...newAuthProps}
// Your custom auth methods
customMethods={customMethods}
// Still need to call `onAuthMethodSelect` function from
// `newAuthProps` to store the legacy data correctly.
// Also make sure to store the data about your component
// being selected/unselected.
onAuthMethodSelect={(method) => {
// handle selecting of custom methods
// sigV4Id
if (sigV4AuthToggleEnabled) {
setSigV4Selected(method === sigV4Id);
// mutate jsonData here to store the selected option because of auth component issue with onOptionsChange being overridden
options.jsonData.sigV4Auth = method === sigV4Id;
}
// Azure
@ -150,7 +141,16 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
azureAuthSettings.setAzureAuthEnabled(options, method === azureAuthId);
}
newAuthProps.onAuthMethodSelect(method);
onOptionsChange({
...options,
basicAuth: method === AuthMethod.BasicAuth,
withCredentials: method === AuthMethod.CrossSiteCredentials,
jsonData: {
...options.jsonData,
sigV4Auth: method === sigV4Id,
oauthPassThru: method === AuthMethod.OAuthForward,
},
});
}}
// If your method is selected pass its id to `selectedMethod`,
// otherwise pass the id from converted legacy data

View File

@ -46,6 +46,7 @@ export interface PromOptions extends DataSourceJsonData {
incrementalQueryOverlapWindow?: string;
disableRecordingRules?: boolean;
sigV4Auth?: boolean;
oauthPassThru?: boolean;
}
export type ExemplarTraceIdDestination = {