mirror of https://github.com/dapr/cli.git
add config switch (#46)
This commit is contained in:
parent
ce7a31b8f6
commit
427981528a
|
@ -19,6 +19,7 @@ import (
|
|||
|
||||
var appPort int
|
||||
var appID string
|
||||
var configFile string
|
||||
var port int
|
||||
var image string
|
||||
|
||||
|
@ -55,6 +56,7 @@ var RunCmd = &cobra.Command{
|
|||
AppID: appID,
|
||||
AppPort: appPort,
|
||||
Port: port,
|
||||
ConfigFile: configFile,
|
||||
Arguments: args,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -184,6 +186,7 @@ var RunCmd = &cobra.Command{
|
|||
func init() {
|
||||
RunCmd.Flags().IntVarP(&appPort, "app-port", "", -1, "the port your application is listening on")
|
||||
RunCmd.Flags().StringVarP(&appID, "app-id", "", "", "an id for your application, used for service discovery")
|
||||
RunCmd.Flags().StringVarP(&configFile, "config", "", "", "Actions configuration file")
|
||||
RunCmd.Flags().IntVarP(&port, "port", "p", -1, "the port for Actions to listen on")
|
||||
RunCmd.Flags().StringVarP(&image, "image", "", "", "the image to build the code in. input is repository/image")
|
||||
RunCmd.Flags().BoolVar(&kubernetesMode, "kubernetes", false, "Build and deploy your app and Actions to a Kubernetes cluster")
|
||||
|
|
|
@ -17,10 +17,11 @@ import (
|
|||
)
|
||||
|
||||
type RunConfig struct {
|
||||
AppID string
|
||||
AppPort int
|
||||
Port int
|
||||
Arguments []string
|
||||
AppID string
|
||||
AppPort int
|
||||
Port int
|
||||
ConfigFile string
|
||||
Arguments []string
|
||||
}
|
||||
|
||||
type RunOutput struct {
|
||||
|
@ -42,7 +43,7 @@ type component struct {
|
|||
} `json:"spec"`
|
||||
}
|
||||
|
||||
func getActionsCommand(appID string, actionsPort int, appPort int) (*exec.Cmd, int, error) {
|
||||
func getActionsCommand(appID string, actionsPort int, appPort int, configFile string) (*exec.Cmd, int, error) {
|
||||
if actionsPort < 0 {
|
||||
port, err := freeport.GetFreePort()
|
||||
if err != nil {
|
||||
|
@ -79,6 +80,11 @@ func getActionsCommand(appID string, actionsPort int, appPort int) (*exec.Cmd, i
|
|||
|
||||
args = append(args, fmt.Sprintf("%v", grpcPort))
|
||||
|
||||
if configFile != "" {
|
||||
args = append(args, "--config")
|
||||
args = append(args, configFile)
|
||||
}
|
||||
|
||||
cmd := exec.Command(actionsCMD, args...)
|
||||
return cmd, actionsPort, nil
|
||||
}
|
||||
|
@ -180,7 +186,7 @@ func Run(config *RunConfig) (*RunOutput, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
actionsCMD, actionsPort, err := getActionsCommand(appID, config.Port, config.AppPort)
|
||||
actionsCMD, actionsPort, err := getActionsCommand(appID, config.Port, config.AppPort, config.ConfigFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue