Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
feat(client): use unix pipes with config:push
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson committed Dec 12, 2015
1 parent dfe0a3a commit 282a11b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 12 additions & 2 deletions client/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -202,13 +203,22 @@ func ConfigPull(appID string, interactive bool, overwrite bool) error {
}

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

if err != nil {
return err
}

if (stat.Mode() & os.ModeCharDevice) != 0 {
fmt.Println(`No file input. ex: 'deis config:push < filename'.
See 'deis help config:push' for more information`)
}

buffer := new(bytes.Buffer)
buffer.ReadFrom(os.Stdin)
contents := buffer.String()

config := strings.Split(string(contents), "\n")
return ConfigSet(appID, config[:len(config)-1])
}
Expand Down
7 changes: 3 additions & 4 deletions client/parser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ func configPush(argv []string) error {
Sets environment variables for an application.
The environment is read from <path>. This file can be read by foreman
to load the local environment for your app.
to load the local environment for your app. The file should be piped via
stdin, for example 'deis config:push < .env'
Usage: deis config:push [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
-p <path>, --path=<path>
a path leading to an environment file [default: .env]
`

args, err := docopt.Parse(usage, argv, true, "", false, true)
Expand All @@ -170,5 +169,5 @@ Options:
return err
}

return cmd.ConfigPush(safeGetValue(args, "--app"), safeGetValue(args, "--path"))
return cmd.ConfigPush(safeGetValue(args, "--app"))
}

0 comments on commit 282a11b

Please sign in to comment.