Transformations: Avoid mutation during variable interpolation (#101594)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { MonoTypeOperatorFunction, Observable, of } from 'rxjs';
|
||||
import { map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
@@ -12,9 +13,6 @@ import {
|
||||
import { getFrameMatchers } from './matchers';
|
||||
import { standardTransformersRegistry, TransformerRegistryItem } from './standardTransformersRegistry';
|
||||
|
||||
// when running within Scenes, we can skip var interpolation, since it's already handled upstream
|
||||
const isScenes = window.__grafanaSceneContext != null;
|
||||
|
||||
const getOperator =
|
||||
(config: DataTransformerConfig, ctx: DataTransformContext): MonoTypeOperatorFunction<DataFrame[]> =>
|
||||
(source) => {
|
||||
@@ -27,9 +25,12 @@ const getOperator =
|
||||
const defaultOptions = info.transformation.defaultOptions ?? {};
|
||||
const options = { ...defaultOptions, ...config.options };
|
||||
|
||||
// when running within Scenes, we can skip var interpolation, since it's already handled upstream
|
||||
const isScenes = window.__grafanaSceneContext != null;
|
||||
|
||||
const interpolated = isScenes
|
||||
? options
|
||||
: deepIterate(options, (v) => {
|
||||
: deepIterate(cloneDeep(options), (v) => {
|
||||
if (typeof v === 'string') {
|
||||
return ctx.interpolate(v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user