@@ -206,7 +206,7 @@ func (cfg *Config) Unmarshal(cfgStr string) (err error) {
206206 }()
207207
208208 // expand variables
209- cfgStr = expandEnvVars (cfgStr )
209+ cfgStr = env . ExpandEnvVars (cfgStr )
210210
211211 cfgBytes := []byte (cfgStr )
212212 _ , errStat := os .Stat (cfgStr )
@@ -1644,7 +1644,7 @@ type CDCOptions struct {
16441644 SnapshotRunDuration * string `json:"snapshot_run_duration,omitempty" yaml:"snapshot_run_duration,omitempty"`
16451645
16461646 // Batching
1647- RunMaxEvents * int `json:"run_max_events,omitempty" yaml:"run_max_events,omitempty"`
1647+ RunMaxEvents * int `json:"run_max_events,omitempty" yaml:"run_max_events,omitempty"`
16481648 RunMaxDuration * string `json:"run_max_duration,omitempty" yaml:"run_max_duration,omitempty"`
16491649
16501650 // Delete behavior
@@ -1834,8 +1834,8 @@ var TargetDBOptionsDefault = TargetOptions{
18341834}
18351835
18361836var CDCOptionsDefault = CDCOptions {
1837- RunMaxEvents : g .Int (100000 ),
1838- RunMaxDuration : g .String ("10m" ),
1837+ RunMaxEvents : g .Int (100000 ),
1838+ RunMaxDuration : g .String ("10m" ),
18391839 SnapshotStart : g .String ("now" ),
18401840 SoftDelete : g .Bool (false ),
18411841 RetryAttempts : g .Int (3 ),
@@ -2033,17 +2033,6 @@ func castKeyArray(keyI any) (key []string) {
20332033 return
20342034}
20352035
2036- // expandEnvVars replaces $KEY or ${KEY} with its environment variable value
2037- // only if the variable is present in the environment.
2038- // If not present, $KEY or ${KEY} will remain in the config text.
2039- func expandEnvVars (text string ) string {
2040- for key , value := range g .KVArrToMap (os .Environ ()... ) {
2041- text = strings .ReplaceAll (text , "$" + key + "" , value )
2042- text = strings .ReplaceAll (text , "${" + key + "}" , value )
2043- }
2044- return text
2045- }
2046-
20472036func cleanConnURL (payload , connURL string ) string {
20482037 cleanSource := strings .Split (connURL , "://" )[0 ] + "://"
20492038 payload = strings .ReplaceAll (payload , g .Marshal (connURL ), g .Marshal (cleanSource ))
0 commit comments