mirror of https://github.com/dapr/cli.git
fix: population of the schedulerhostaddress in self-hosted mode (#1475)
* fix: population of the schedulerhostaddress in self-hosted mode The scheduler host address is pre-populated when using the self-hosted mode multi-app run similarly to the single app run. Kubernetes multi-app run is not affected and you will still need to specify a scheduler host address. Signed-off-by: mikeee <hey@mike.ee> * chore: lint Signed-off-by: mikeee <hey@mike.ee> --------- Signed-off-by: mikeee <hey@mike.ee> Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
This commit is contained in:
parent
104849bc74
commit
3acfa7d7e4
14
cmd/run.go
14
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)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue