Skip to content

Commit 3559772

Browse files
committed
address comment
1 parent 738f4f7 commit 3559772

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

controllers/spec/sink.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ package spec
1919

2020
import (
2121
"context"
22-
"regexp"
23-
"strings"
24-
2522
"github.com/streamnative/function-mesh/utils"
2623
"google.golang.org/protobuf/encoding/protojson"
2724
appsv1 "k8s.io/api/apps/v1"
2825
autov2 "k8s.io/api/autoscaling/v2"
2926
v1 "k8s.io/api/batch/v1"
3027
corev1 "k8s.io/api/core/v1"
3128
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29+
"regexp"
3230
"sigs.k8s.io/controller-runtime/pkg/client"
3331

3432
"github.com/streamnative/function-mesh/api/compute/v1alpha1"
@@ -226,16 +224,7 @@ func MakeSinkCommand(sink *v1alpha1.Sink) []string {
226224
hasPulsarctl = true
227225
hasWget = true
228226
}
229-
mountPath := spec.Java.Jar
230-
if utils.EnableInitContainers {
231-
// for relative path, volume should be mounted to the WorkDir
232-
// and path also should be under the $WorkDir dir
233-
if !strings.HasPrefix(spec.Java.Jar, "/") {
234-
mountPath = WorkDir + spec.Java.Jar
235-
} else if !strings.HasPrefix(spec.Java.Jar, WorkDir) {
236-
mountPath = strings.Replace(spec.Java.Jar, "/", WorkDir, 1)
237-
}
238-
}
227+
mountPath := extractMountPath(spec.Java.Jar)
239228
return MakeJavaFunctionCommand(spec.Java.JarLocation, mountPath,
240229
spec.Name, spec.ClusterName,
241230
GenerateJavaLogConfigCommand(spec.Java, spec.LogTopicAgent),

controllers/spec/source.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ package spec
2020
import (
2121
"context"
2222
"fmt"
23-
"regexp"
24-
"strings"
25-
2623
"github.com/streamnative/function-mesh/utils"
2724
"google.golang.org/protobuf/encoding/protojson"
2825
appsv1 "k8s.io/api/apps/v1"
2926
autov2 "k8s.io/api/autoscaling/v2"
3027
v1 "k8s.io/api/batch/v1"
3128
corev1 "k8s.io/api/core/v1"
3229
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30+
"regexp"
3331
"sigs.k8s.io/controller-runtime/pkg/client"
3432

3533
"github.com/streamnative/function-mesh/api/compute/v1alpha1"
@@ -174,16 +172,7 @@ func makeSourceCommand(source *v1alpha1.Source) []string {
174172
hasWget = true
175173
}
176174

177-
mountPath := spec.Java.Jar
178-
if utils.EnableInitContainers {
179-
// for relative path, volume should be mounted to the WorkDir
180-
// and path also should be under the $WorkDir dir
181-
if !strings.HasPrefix(spec.Java.Jar, "/") {
182-
mountPath = WorkDir + spec.Java.Jar
183-
} else if !strings.HasPrefix(spec.Java.Jar, WorkDir) {
184-
mountPath = strings.Replace(spec.Java.Jar, "/", WorkDir, 1)
185-
}
186-
}
175+
mountPath := extractMountPath(spec.Java.Jar)
187176
return MakeJavaFunctionCommand(spec.Java.JarLocation, mountPath,
188177
spec.Name, spec.ClusterName,
189178
GenerateJavaLogConfigCommand(spec.Java, spec.LogTopicAgent),

0 commit comments

Comments
 (0)