@@ -15,7 +15,9 @@ import (
15
15
func SetField (ctx context.Context , key string , value interface {}) context.Context {
16
16
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
17
17
18
- lOpts = logging .WithField (key , value )(lOpts )
18
+ // Copy to prevent slice/map aliasing issues.
19
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
20
+ lOpts = logging .WithField (key , value )(lOpts .Copy ())
19
21
20
22
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
21
23
}
@@ -152,7 +154,9 @@ func Error(ctx context.Context, msg string, additionalFields ...map[string]inter
152
154
func OmitLogWithFieldKeys (ctx context.Context , keys ... string ) context.Context {
153
155
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
154
156
155
- lOpts = logging .WithOmitLogWithFieldKeys (keys ... )(lOpts )
157
+ // Copy to prevent slice/map aliasing issues.
158
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
159
+ lOpts = logging .WithOmitLogWithFieldKeys (keys ... )(lOpts .Copy ())
156
160
157
161
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
158
162
}
@@ -174,7 +178,9 @@ func OmitLogWithFieldKeys(ctx context.Context, keys ...string) context.Context {
174
178
func OmitLogWithMessageRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
175
179
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
176
180
177
- lOpts = logging .WithOmitLogWithMessageRegexes (expressions ... )(lOpts )
181
+ // Copy to prevent slice/map aliasing issues.
182
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
183
+ lOpts = logging .WithOmitLogWithMessageRegexes (expressions ... )(lOpts .Copy ())
178
184
179
185
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
180
186
}
@@ -195,7 +201,9 @@ func OmitLogWithMessageRegexes(ctx context.Context, expressions ...*regexp.Regex
195
201
func OmitLogWithMessageStrings (ctx context.Context , matchingStrings ... string ) context.Context {
196
202
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
197
203
198
- lOpts = logging .WithOmitLogWithMessageStrings (matchingStrings ... )(lOpts )
204
+ // Copy to prevent slice/map aliasing issues.
205
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
206
+ lOpts = logging .WithOmitLogWithMessageStrings (matchingStrings ... )(lOpts .Copy ())
199
207
200
208
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
201
209
}
@@ -217,7 +225,9 @@ func OmitLogWithMessageStrings(ctx context.Context, matchingStrings ...string) c
217
225
func MaskFieldValuesWithFieldKeys (ctx context.Context , keys ... string ) context.Context {
218
226
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
219
227
220
- lOpts = logging .WithMaskFieldValuesWithFieldKeys (keys ... )(lOpts )
228
+ // Copy to prevent slice/map aliasing issues.
229
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
230
+ lOpts = logging .WithMaskFieldValuesWithFieldKeys (keys ... )(lOpts .Copy ())
221
231
222
232
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
223
233
}
@@ -241,7 +251,9 @@ func MaskFieldValuesWithFieldKeys(ctx context.Context, keys ...string) context.C
241
251
func MaskAllFieldValuesRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
242
252
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
243
253
244
- lOpts = logging .WithMaskAllFieldValuesRegexes (expressions ... )(lOpts )
254
+ // Copy to prevent slice/map aliasing issues.
255
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
256
+ lOpts = logging .WithMaskAllFieldValuesRegexes (expressions ... )(lOpts .Copy ())
245
257
246
258
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
247
259
}
@@ -265,7 +277,9 @@ func MaskAllFieldValuesRegexes(ctx context.Context, expressions ...*regexp.Regex
265
277
func MaskAllFieldValuesStrings (ctx context.Context , matchingStrings ... string ) context.Context {
266
278
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
267
279
268
- lOpts = logging .WithMaskAllFieldValuesStrings (matchingStrings ... )(lOpts )
280
+ // Copy to prevent slice/map aliasing issues.
281
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
282
+ lOpts = logging .WithMaskAllFieldValuesStrings (matchingStrings ... )(lOpts .Copy ())
269
283
270
284
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
271
285
}
@@ -287,7 +301,9 @@ func MaskAllFieldValuesStrings(ctx context.Context, matchingStrings ...string) c
287
301
func MaskMessageRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
288
302
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
289
303
290
- lOpts = logging .WithMaskMessageRegexes (expressions ... )(lOpts )
304
+ // Copy to prevent slice/map aliasing issues.
305
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
306
+ lOpts = logging .WithMaskMessageRegexes (expressions ... )(lOpts .Copy ())
291
307
292
308
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
293
309
}
@@ -309,7 +325,9 @@ func MaskMessageRegexes(ctx context.Context, expressions ...*regexp.Regexp) cont
309
325
func MaskMessageStrings (ctx context.Context , matchingStrings ... string ) context.Context {
310
326
lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
311
327
312
- lOpts = logging .WithMaskMessageStrings (matchingStrings ... )(lOpts )
328
+ // Copy to prevent slice/map aliasing issues.
329
+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
330
+ lOpts = logging .WithMaskMessageStrings (matchingStrings ... )(lOpts .Copy ())
313
331
314
332
return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
315
333
}
0 commit comments