@@ -45,4 +45,69 @@ Return the proper Replicator image name
45
45
{ {- $repositoryName := .Values.image.repository -} }
46
46
{ {- $tag := .Values.image.tag | toString -} }
47
47
{ {- printf " %s/%s:%s" $registryName $repositoryName $tag -} }
48
+ { {- end -} }
49
+
50
+ { {/*
51
+ Checks if replicator is configured to use javascript transform
52
+ */} }
53
+ { {- define " replicator.shouldUseJavascriptTransform" -} }
54
+ { {- if and
55
+ .Values.replicator.transform
56
+ (eq .Values.replicator.transform.type " js" )
57
+ .Values.replicator.transform.config
58
+ .Values.transformJs
59
+ -} }
60
+ { {- print " true" } }
61
+ { {- end -} }
62
+ { {- end -} }
63
+
64
+ { {/*
65
+ Checks if replicator is configured to use a custom partitioner
66
+ */} }
67
+ { {- define " replicator.shouldUseCustomPartitioner" -} }
68
+ { {- if and
69
+ .Values.replicator.sink.partitioner
70
+ .Values.partitionerJs
71
+ -} }
72
+ { {- print " true" } }
73
+ { {- end -} }
74
+ { {- end -} }
75
+
76
+ { {- define " replicator.transform.filename" -} }
77
+ { {- if eq (include " replicator.shouldUseJavascriptTransform" .) " true" -} }
78
+ { { printf " %s" (include " replicator.helpers.filename" .Values.replicator.transform.config) } }
79
+ { {- end -} }
80
+ { {- end -} }
81
+
82
+ { {- define " replicator.transform.filepath" -} }
83
+ { {- if eq (include " replicator.shouldUseJavascriptTransform" .) " true" -} }
84
+ { { printf " %s" (include " replicator.helpers.cleansePath" .Values.replicator.transform.config) } }
85
+ { {- end -} }
86
+ { {- end -} }
87
+
88
+ { {- define " replicator.sink.partitioner.filename" -} }
89
+ { {- if eq (include " replicator.shouldUseCustomPartitioner" .) " true" -} }
90
+ { { printf " %s" (include " replicator.helpers.filename" .Values.replicator.sink.partitioner) } }
91
+ { {- end -} }
92
+ { {- end -} }
93
+
94
+ { {- define " replicator.sink.partitioner.filepath" -} }
95
+ { {- if eq (include " replicator.shouldUseCustomPartitioner" .) " true" -} }
96
+ { { printf " %s" (include " replicator.helpers.cleansePath" .Values.replicator.sink.partitioner) } }
97
+ { {- end -} }
98
+ { {- end -} }
99
+
100
+ { {- define " replicator.helpers.filename" -} }
101
+ { {- $file := . -} }
102
+ { {- $filename := last (splitList " /" $file ) -} }
103
+ { {- $filename -} }
104
+ { {- end -} }
105
+
106
+ { {- define " replicator.helpers.cleansePath" -} }
107
+ { {- $path := . -} }
108
+ { {- $path = replace " ./" " /" $path -} }
109
+ { {- if not (hasPrefix " /" $path ) -} }
110
+ { {- $path = printf " /%s" $path -} }
111
+ { {- end -} }
112
+ { {- $path -} }
48
113
{ {- end -} }
0 commit comments