Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
running Kompose from source
Browse files Browse the repository at this point in the history
  • Loading branch information
prachidamle committed Sep 26, 2018
1 parent accf43c commit 97f21a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
12 changes: 2 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func main() {
Usage: "An absolute path to an alternate Rancher compose file (default: rancher-compose.yml)",
Value: "rancher-compose.yml",
},
cli.StringFlag{
Name: "kompose-tool-path",
Usage: "An absolute path to the Kompose tool",
},
}

app.Run(os.Args)
Expand Down Expand Up @@ -64,12 +60,8 @@ func StartTool(c *cli.Context) {
logrus.Fatalf("Failed parsing the compose files, error: %v", err)
}

if t.komposeTool != "" {
err := runKompose(t)
if err != nil {
logrus.Errorf("Failed running the Kompose tool to generate Kuberntes YAML files, error: %v", err)
}
}
runKompose(t)

}

func beforeApp(c *cli.Context) error {
Expand Down
23 changes: 11 additions & 12 deletions tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"reflect"
"strings"

"os/exec"

"fmt"

"github.com/kubernetes/kompose/pkg/app"
"github.com/kubernetes/kompose/pkg/kobject"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -259,16 +259,15 @@ func readRancherCompose(t *ToolArgs) (*RancherComposeConfig, error) {
return rancherConfig, nil
}

func runKompose(t *ToolArgs) error {
func runKompose(t *ToolArgs) {
logrus.Infof("---Running Kompose tool on the docker-compose.yml---")
e := exec.Command(t.komposeTool, "convert", "-f", t.dockerComposeFile)
e.Stdout = os.Stdout
e.Stderr = os.Stderr
err := e.Run()
if err != nil {
return fmt.Errorf("Error running the Kompose tool: %v", err)
} else {
logrus.Infof("---Kompose has created the Kubernetes YAML files for your 1.6 services---")
ConvertOpt := kobject.ConvertOptions{
ToStdout: false,
Provider: "kubernetes",
GenerateYaml: true,
InputFiles: []string{t.dockerComposeFile},
}
return nil

app.Convert(ConvertOpt)
logrus.Infof("---Kompose has created the Kubernetes YAML files for your 1.6 services---")
}

0 comments on commit 97f21a8

Please sign in to comment.