feat: allow set-pipeline to take configure from stdin. this would make pipeline migration from one cluster to the other easier.
@@ -2,6 +2,9 @@ package atc
import (
"fmt"
+ "io"
+ "io/ioutil"
+ "os"
"path/filepath"
"strings"
@@ -15,6 +18,21 @@ func (path *PathFlag) UnmarshalFlag(value string) error {
return nil
}
+ if value == "-" {
+ tempf, err := ioutil.TempFile("", "fly-set-pipeline")
+ if err != nil {
+ return fmt.Errorf("failed to create a temp file")
+ }
+ defer tempf.Close()
+
+ _, err = io.Copy(tempf, os.Stdin)
+ if err != nil {
+ return fmt.Errorf("failed to write temp file: %s", err.Error())
+ }
+ *path = PathFlag(tempf.Name())
+ return nil
+ }
+
matches, err := filepath.Glob(value)
if err != nil {
return fmt.Errorf("failed to expand path '%s': %s", value, err)
