diff --git a/cmd/run.go b/cmd/run.go index f91c772e6..fe1b95cbd 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -524,6 +524,9 @@ func executeRun(runTemplateName, runFilePath string, apps []runfileconfig.App) ( exitWithError = true break } + + runConfig.SchedulerHostAddress = validateSchedulerHostAddress(daprVer.RuntimeVersion, runConfig.SchedulerHostAddress) + // Combined multiwriter for logs. var appDaprdWriter io.Writer // appLogWriter is used when app command is present. @@ -664,6 +667,17 @@ func executeRunWithAppsConfigFile(runFilePath string, k8sEnabled bool) { } } +// populate the scheduler host address based on the dapr version. +func validateSchedulerHostAddress(version, address string) string { + // If no SchedulerHostAddress is supplied, set it to default value. + if semver.Compare(fmt.Sprintf("v%v", version), "v1.15.0-rc.0") == 1 { + if address == "" { + return "localhost:50006" + } + } + return address +} + func getRunConfigFromRunFile(runFilePath string) (runfileconfig.RunFileConfig, []runfileconfig.App, error) { config := runfileconfig.RunFileConfig{} apps, err := config.GetApps(runFilePath) diff --git a/cmd/run_test.go b/cmd/run_test.go new file mode 100644 index 000000000..30b166352 --- /dev/null +++ b/cmd/run_test.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestValidateSchedulerHostAddress(t *testing.T) { + t.Run("test scheduler host address - v1.14.0-rc.0", func(t *testing.T) { + address := validateSchedulerHostAddress("1.14.0-rc.0", "") + assert.Equal(t, "", address) + }) + + t.Run("test scheduler host address - v1.15.0-rc.0", func(t *testing.T) { + address := validateSchedulerHostAddress("1.15.0", "") + assert.Equal(t, "localhost:50006", address) + }) +}