Skip to content

Commit 4063955

Browse files
authored
Merge pull request #739 from slingdata-io/v1.5.17
V1.5.17
2 parents 2c72bb0 + 21bafd7 commit 4063955

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

core/env/env.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,3 +774,14 @@ func Clean(props map[string]string, line string) string {
774774
}
775775
return line
776776
}
777+
778+
// expandEnvVars replaces $KEY or ${KEY} with its environment variable value
779+
// only if the variable is present in the environment.
780+
// If not present, $KEY or ${KEY} will remain in the config text.
781+
func ExpandEnvVars(text string) string {
782+
for key, value := range g.KVArrToMap(os.Environ()...) {
783+
text = strings.ReplaceAll(text, "$"+key+"", value)
784+
text = strings.ReplaceAll(text, "${"+key+"}", value)
785+
}
786+
return text
787+
}

core/sling/config.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

18361836
var 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-
20472036
func cleanConnURL(payload, connURL string) string {
20482037
cleanSource := strings.Split(connURL, "://")[0] + "://"
20492038
payload = strings.ReplaceAll(payload, g.Marshal(connURL), g.Marshal(cleanSource))

core/sling/replication.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type ReplicationConfig struct {
4444
maps replicationConfigMaps // raw maps for validation
4545
state *ReplicationState
4646

47-
CDCRunner CDCRunner
47+
CDCRunner CDCRunner `json:"-"`
4848
}
4949

5050
type CDCRunner interface {

0 commit comments

Comments
 (0)