Skip to content

Commit 00a20c3

Browse files
feat(client): use unix pipes with config:push
1 parent 34ff500 commit 00a20c3

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

client/cmd/config.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"bytes"
45
"encoding/base64"
56
"fmt"
67
"io/ioutil"
@@ -202,13 +203,27 @@ func ConfigPull(appID string, interactive bool, overwrite bool) error {
202203
}
203204

204205
// ConfigPush pushes an app's config from a file.
205-
func ConfigPush(appID string, fileName string) error {
206-
contents, err := ioutil.ReadFile(fileName)
206+
func ConfigPush(appID, fileName string) error {
207+
stat, err := os.Stdin.Stat()
207208

208209
if err != nil {
209210
return err
210211
}
211212

213+
var contents []byte
214+
215+
if (stat.Mode() & os.ModeCharDevice) == 0 {
216+
buffer := new(bytes.Buffer)
217+
buffer.ReadFrom(os.Stdin)
218+
contents = buffer.Bytes()
219+
} else {
220+
contents, err = ioutil.ReadFile(fileName)
221+
222+
if err != nil {
223+
return err
224+
}
225+
}
226+
212227
config := strings.Split(string(contents), "\n")
213228
return ConfigSet(appID, config[:len(config)-1])
214229
}

client/parser/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ func configPush(argv []string) error {
152152
usage := `
153153
Sets environment variables for an application.
154154
155-
The environment is read from <path>. This file can be read by foreman
156-
to load the local environment for your app.
155+
This file can be read by foreman
156+
to load the local environment for your app. The file should be piped via
157+
stdin, 'deis config:push < .env', or using the --path option.
157158
158159
Usage: deis config:push [options]
159160

0 commit comments

Comments
 (0)