Skip to content

Commit

Permalink
Use bash -c instead of sh -c (#714)
Browse files Browse the repository at this point in the history
* Use `bash -c` instead of `sh -c`

* Format

* Fix unittest
  • Loading branch information
jiangpengcheng authored Jan 22, 2024
1 parent b180690 commit cc3882d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ package spec
import (
"bytes"
"context"
"regexp"

autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"

// used for template
_ "embed"
Expand All @@ -32,12 +29,14 @@ import (
"html/template"
"os"
"reflect"
"regexp"
"sort"
"strconv"
"strings"

appsv1 "k8s.io/api/apps/v1"
autov2 "k8s.io/api/autoscaling/v2"
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
v1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -354,7 +353,7 @@ func MakeJavaFunctionCommand(downloadPath, packageFile, name, clusterName, gener
authProvided, tlsProvided, tlsConfig, authConfig), " ")
processCommand = downloadCommand + " && " + processCommand
}
return []string{"sh", "-c", processCommand}
return []string{"bash", "-c", processCommand}
}

func MakePythonFunctionCommand(downloadPath, packageFile, name, clusterName, generateLogConfigCommand, details, uid string,
Expand All @@ -371,7 +370,7 @@ func MakePythonFunctionCommand(downloadPath, packageFile, name, clusterName, gen
tlsProvided, tlsConfig, authConfig), " ")
processCommand = downloadCommand + " && " + processCommand
}
return []string{"sh", "-c", processCommand}
return []string{"bash", "-c", processCommand}
}

func MakeGoFunctionCommand(downloadPath, goExecFilePath string, function *v1alpha1.Function) []string {
Expand All @@ -390,7 +389,7 @@ func MakeGoFunctionCommand(downloadPath, goExecFilePath string, function *v1alph
function.Spec.Pulsar.TLSSecret != "", function.Spec.Pulsar.TLSConfig, function.Spec.Pulsar.AuthConfig), " ")
processCommand = downloadCommand + " && ls -al && pwd &&" + processCommand
}
return []string{"sh", "-c", processCommand}
return []string{"bash", "-c", processCommand}
}

func MakeGenericFunctionCommand(downloadPath, functionFile, language, clusterName, details, uid string, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
Expand Down
2 changes: 1 addition & 1 deletion controllers/spec/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func TestGetSourceRunnerImage(t *testing.T) {
func TestMakeGoFunctionCommand(t *testing.T) {
function := makeGoFunctionSample(TestFunctionName)
commands := MakeGoFunctionCommand("", "/pulsar/go-func", function)
assert.Equal(t, commands[0], "sh")
assert.Equal(t, commands[0], "bash")
assert.Equal(t, commands[1], "-c")
assert.True(t, strings.HasPrefix(commands[2], "SHARD_ID=${POD_NAME##*-} && echo shardId=${SHARD_ID}"))
innerCommands := strings.Split(commands[2], "&&")
Expand Down

0 comments on commit cc3882d

Please sign in to comment.