forked from LaconicNetwork/kompose
Kompose will read input from stdin
Resolves issue #870 for example, ``` $ cat docker-compose.yaml | kompose convert -f - INFO Kubernetes file "frontend-service.yaml" created INFO Kubernetes file "redis-master-service.yaml" created INFO Kubernetes file "redis-slave-service.yaml" created INFO Kubernetes file "frontend-deployment.yaml" created INFO Kubernetes file "redis-master-deployment.yaml" created INFO Kubernetes file "redis-slave-deployment.yaml" created ``` Added integration test for the same. `
This commit is contained in:
@@ -24,6 +24,9 @@ import (
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"bufio"
|
||||
"os"
|
||||
|
||||
"github.com/docker/libcompose/project"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/kubernetes/kompose/pkg/kobject"
|
||||
@@ -199,10 +202,16 @@ func getVersionFromFile(file string) (string, error) {
|
||||
Version string `json:"version"` // This affects YAML as well
|
||||
}
|
||||
var version ComposeVersion
|
||||
|
||||
loadedFile, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
var loadedFile []byte
|
||||
var err error
|
||||
if file == "-" {
|
||||
data := bufio.NewScanner(os.Stdin)
|
||||
loadedFile = data.Bytes()
|
||||
} else {
|
||||
loadedFile, err = ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(loadedFile, &version)
|
||||
|
||||
Reference in New Issue
Block a user