Support read data from stdin
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package compose
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -115,3 +116,18 @@ func handleServiceType(ServiceType string) (string, error) {
|
||||
func normalizeServiceNames(svcName string) string {
|
||||
return strings.Replace(svcName, "_", "-", -1)
|
||||
}
|
||||
|
||||
// ReadFile read data from file or stdin
|
||||
func ReadFile(fileName string) ([]byte, error) {
|
||||
if fileName == "-" {
|
||||
if StdinData == nil {
|
||||
data, err := ioutil.ReadAll(os.Stdin)
|
||||
StdinData = data
|
||||
return data, err
|
||||
} else {
|
||||
return StdinData, nil
|
||||
}
|
||||
}
|
||||
return ioutil.ReadFile(fileName)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user