Skip to content

Commit

Permalink
remove unknown args and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek authored and Abhishek committed Oct 17, 2016
1 parent 776c948 commit 7e9cb9a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func validateControllers(opt *kobject.ConvertOptions) {

// Convert transforms docker compose or dab file to k8s objects
func Convert(c *cli.Context) {
CheckForunknownArgs(c)
opt := kobject.ConvertOptions{
ToStdout: c.BoolT("stdout"),
CreateChart: c.BoolT("chart"),
Expand Down Expand Up @@ -167,6 +168,7 @@ func Convert(c *cli.Context) {

// Up brings up deployment, svc.
func Up(c *cli.Context) {
CheckForunknownArgs(c)
opt := kobject.ConvertOptions{
InputFile: c.GlobalString("file"),
Replicas: 1,
Expand Down Expand Up @@ -203,6 +205,7 @@ func Up(c *cli.Context) {

// Down deletes all deployment, svc.
func Down(c *cli.Context) {
CheckForunknownArgs(c)
opt := kobject.ConvertOptions{
InputFile: c.GlobalString("file"),
Replicas: 1,
Expand Down Expand Up @@ -253,3 +256,10 @@ func askForConfirmation() bool {
return askForConfirmation()
}
}

func CheckForunknownArgs(c *cli.Context) {
if len(c.Args()) != 0 {
logrus.Fatal("Unknown Argument ", c.Args().First())
}
}

6 changes: 6 additions & 0 deletions script/test/cmd/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mo
# openshift test
convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/output-os.json"

######
# Tests related to unknown arguments with cli commands
convert::expect_failure "kompose up docker $KOMPOSE_ROOT/script/test/fixtures/unknown-arguments/docker-gitlab.yml" "Unknown Argument docker-gitlab.yml"
convert::expect_failure "kompose down docker $KOMPOSE_ROOT/script/test/fixtures/unknown-arguments/docker-gitlab.yml" "Unknown Argument docker-gitlab.yml"
convert::expect_failure "kompose convert docker $KOMPOSE_ROOT/script/test/fixtures/unknown-arguments/docker-gitlab.yml" "Unknown Argument docker-gitlab.yml"

exit $EXIT_STATUS

0 comments on commit 7e9cb9a

Please sign in to comment.