From f14ba32ea6400528c67d78d2f88519ad4c3cd306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jamr=C3=B3z?= Date: Tue, 16 Jul 2024 11:50:38 +0200 Subject: [PATCH] Query Library: Use current namespace when calling API (#90423) * Use the current namespace * Enable PeakQ API * Enable PeakQ API when Query API is enabled * Enable PeakQ API when Query API & Query Library are enabled --- pkg/registry/apis/peakq/register.go | 5 +++-- public/app/features/query-library/api/query.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/registry/apis/peakq/register.go b/pkg/registry/apis/peakq/register.go index 2cf740cb064..240078c5aa1 100644 --- a/pkg/registry/apis/peakq/register.go +++ b/pkg/registry/apis/peakq/register.go @@ -31,8 +31,9 @@ func NewPeakQAPIBuilder() *PeakQAPIBuilder { } func RegisterAPIService(features featuremgmt.FeatureToggles, apiregistration builder.APIRegistrar, reg prometheus.Registerer) *PeakQAPIBuilder { - if !features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs) { - return nil // skip registration unless opting into experimental apis + if !((features.IsEnabledGlobally(featuremgmt.FlagQueryService) && features.IsEnabledGlobally(featuremgmt.FlagQueryLibrary)) || + features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs)) { + return nil // skip registration unless explicitly added (or all experimental are added) } builder := NewPeakQAPIBuilder() apiregistration.RegisterAPI(NewPeakQAPIBuilder()) diff --git a/public/app/features/query-library/api/query.ts b/public/app/features/query-library/api/query.ts index b3baced6237..2d08c1736ae 100644 --- a/public/app/features/query-library/api/query.ts +++ b/public/app/features/query-library/api/query.ts @@ -1,6 +1,7 @@ import { BaseQueryFn } from '@reduxjs/toolkit/query/react'; import { lastValueFrom } from 'rxjs'; +import { config } from '@grafana/runtime'; import { BackendSrvRequest, getBackendSrv, isFetchError } from '@grafana/runtime/src/services/backendSrv'; import { DataQuerySpecResponse } from './types'; @@ -22,7 +23,7 @@ export enum QueryTemplateKinds { * * @alpha */ -export const BASE_URL = `/apis/${API_VERSION}/namespaces/default/querytemplates/`; +export const BASE_URL = `/apis/${API_VERSION}/namespaces/${config.namespace}/querytemplates/`; // URL is optional for these requests interface QueryLibraryBackendRequest extends Pick {