diff --git a/cmd/run.go b/cmd/run.go index f1491e305..773ed0e09 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -108,6 +108,9 @@ dapr run --run-file dapr.yaml # Run multiple apps by providing a directory path containing the run config file(dapr.yaml) dapr run --run-file /path/to/directory +# Run multiple apps by providing config via stdin +cat dapr.template.yaml | envsubst | dapr run --run-file - + # Run multiple apps in Kubernetes by proficing path of a run config file dapr run --run-file dapr.yaml -k @@ -1008,6 +1011,9 @@ func putDaprLogFilePathInMeta(runE *runExec.RunExec, daprLogFilePath string) { // If the provided path is a path to a YAML file then return the same. // Else it returns the path of "dapr.yaml" in the provided directory. func getRunFilePath(path string) (string, error) { + if path == "-" { + return path, nil // will be read from stdin later. + } fileInfo, err := os.Stat(path) if err != nil { return "", fmt.Errorf("error getting file info for %s: %w", path, err) diff --git a/utils/utils.go b/utils/utils.go index 977e57866..483bf85f7 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -392,6 +392,13 @@ func ResolveHomeDir(filePath string) (string, error) { } func ReadFile(filePath string) ([]byte, error) { + if filePath == "-" { + bytes, err := io.ReadAll(os.Stdin) + if err != nil { + return nil, fmt.Errorf("error in reading the provided app config from stdin: %w", err) + } + return bytes, nil + } bytes, err := os.ReadFile(filePath) if err != nil { return nil, fmt.Errorf("error in reading the provided app config file: %w", err)