@@ -17,10 +17,8 @@ package configsource
17
17
import (
18
18
"context"
19
19
"fmt"
20
- "log"
21
20
"net/url"
22
21
"os"
23
- "strconv"
24
22
"strings"
25
23
26
24
"github.com/knadh/koanf/maps"
@@ -42,22 +40,13 @@ const (
42
40
// typeAndNameSeparator is the separator that is used between type and name in type/name
43
41
// composite keys.
44
42
typeAndNameSeparator = '/'
45
- // dollarDollarCompatEnvVar is a temporary env var to disable backward compatibility (true by default)
46
- dollarDollarCompatEnvVar = "SPLUNK_DOUBLE_DOLLAR_CONFIG_SOURCE_COMPATIBLE"
47
43
)
48
44
49
45
// private error types to help with testability
50
46
type (
51
47
errUnknownConfigSource struct { error }
52
48
)
53
49
54
- var ddBackwardCompatible = func () bool {
55
- if v , err := strconv .ParseBool (strings .ToLower (os .Getenv (dollarDollarCompatEnvVar ))); err == nil {
56
- return v
57
- }
58
- return true
59
- }()
60
-
61
50
type ConfigSource interface {
62
51
// Retrieve goes to the configuration source and retrieves the selected data which
63
52
// contains the value to be injected in the configuration and the corresponding watcher that
@@ -346,56 +335,18 @@ func resolveStringValue(ctx context.Context, configSources map[string]ConfigSour
346
335
w := 0 // number of bytes consumed on this pass
347
336
348
337
switch {
349
- case s [j + 1 ] == expandPrefixChar :
350
- // temporary backward compatibility to support updated $${config_source:value} functionality
351
- // in provided configs from 0.37.0 until 0.42.0
352
- bwCompatibilityRequired := false
353
-
354
- var expanded , sourceName string
355
- var ww int
356
- if ddBackwardCompatible && len (s [j + 1 :]) > 2 {
357
- if s [j + 2 ] == '{' {
358
- if expanded , ww , sourceName = getBracketedExpandableContent (s , j + 2 ); sourceName != "" {
359
- bwCompatibilityRequired = true
360
- }
361
- } else {
362
- if expanded , ww , sourceName = getBareExpandableContent (s , j + 2 ); sourceName != "" {
363
- if len (expanded ) > (len (sourceName ) + 1 ) {
364
- if ! strings .Contains (expanded [len (sourceName )+ 1 :], "$" ) {
365
- bwCompatibilityRequired = true
366
- }
367
- }
368
- }
369
- }
370
- }
371
-
372
- if bwCompatibilityRequired {
373
- log .Printf (
374
- `Deprecated config source directive %q has been replaced with %q. Please update your config as necessary as this will be removed in future release. To disable this replacement set the SPLUNK_DOUBLE_DOLLAR_CONFIG_SOURCE_COMPATIBLE environment variable to "false" before restarting the Collector.` ,
375
- s [j :j + 2 + ww ], s [j + 1 :j + 2 + ww ],
376
- )
377
- expandableContent = expanded
378
- w = ww + 1
379
- cfgSrcName = sourceName
380
- } else {
381
- // Escaping the prefix so $$ becomes a single $ without attempting
382
- // to treat the string after it as a config source or env var.
383
- expandableContent = string (expandPrefixChar )
384
- w = 1 // consumed a single char
385
- }
386
-
387
338
case s [j + 1 ] == '{' :
388
339
expandableContent , w , cfgSrcName = getBracketedExpandableContent (s , j + 1 )
389
-
390
340
default :
341
+ // TODO: To be deprecated removed to align with the upstream behavior
391
342
expandableContent , w , cfgSrcName = getBareExpandableContent (s , j + 1 )
392
-
393
343
}
394
344
395
345
// At this point expandableContent contains a string to be expanded, evaluate and expand it.
396
346
switch {
397
347
case cfgSrcName == "" :
398
348
// Not a config source, expand as os.ExpandEnv
349
+ // TODO: Align with confmap.strictlyTypedInput feature gate
399
350
buf = osExpandEnv (buf , expandableContent , w )
400
351
401
352
default :
0 commit comments