Merge pull request #139 from ngtuna/global-flag

make --file as global flag
This commit is contained in:
Tuna 2016-09-06 23:47:58 +07:00 committed by GitHub
commit 3cfa12987a
4 changed files with 24 additions and 34 deletions

View File

@ -88,7 +88,7 @@ func validateFlags(opt kobject.ConvertOptions, singleOutput bool, dabFile, input
// Convert transforms docker compose or dab file to k8s objects
func Convert(c *cli.Context) {
inputFile := c.String("file")
inputFile := c.GlobalString("file")
dabFile := c.String("bundle")
outFile := c.String("out")
generateYaml := c.BoolT("yaml")
@ -170,7 +170,7 @@ func Up(c *cli.Context) {
}
client := client.NewOrDie(clientConfig)
inputFile := c.String("file")
inputFile := c.GlobalString("file")
dabFile := c.String("bundle")
komposeObject := kobject.KomposeObject{
@ -220,7 +220,7 @@ func Down(c *cli.Context) {
}
client := client.NewOrDie(clientConfig)
inputFile := c.String("file")
inputFile := c.GlobalString("file")
dabFile := c.String("bundle")
komposeObject := kobject.KomposeObject{

View File

@ -32,12 +32,6 @@ func ConvertCommand() cli.Command {
app.Convert(c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "file,f",
Usage: fmt.Sprintf("Specify an alternate compose file (default: %s)", app.DefaultComposeFile),
Value: app.DefaultComposeFile,
EnvVar: "COMPOSE_FILE",
},
cli.StringFlag{
Name: "bundle,dab",
Usage: "Specify a Distributed Application Bundle (DAB) file",
@ -94,12 +88,6 @@ func UpCommand() cli.Command {
app.Up(c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "file,f",
Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile),
Value: app.DefaultComposeFile,
EnvVar: "COMPOSE_FILE",
},
cli.StringFlag{
Name: "bundle,dab",
Usage: "Specify a Distributed Application Bundle (DAB) file",
@ -118,12 +106,6 @@ func DownCommand() cli.Command {
app.Down(c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "file,f",
Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile),
Value: app.DefaultComposeFile,
EnvVar: "COMPOSE_FILE",
},
cli.StringFlag{
Name: "bundle,dab",
Usage: "Specify a Distributed Application Bundle (DAB) file",
@ -135,5 +117,12 @@ func DownCommand() cli.Command {
// CommonFlags defines the flags that are in common for all subcommands.
func CommonFlags() []cli.Flag {
return []cli.Flag{}
return []cli.Flag{
cli.StringFlag{
Name: "file,f",
Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile),
Value: app.DefaultComposeFile,
EnvVar: "COMPOSE_FILE",
},
}
}

View File

@ -201,3 +201,4 @@ WARN[0000] Unsupported key build - ignoring
WARN[0000] Unsupported key cap_add - ignoring
WARN[0000] Unsupported key dockerfile - ignoring
```

View File

@ -5,42 +5,42 @@ source $KOMPOSE_ROOT/script/test/cmd/lib.sh
#######
# Tests related to docker-compose file in /script/test/fixtures/etherpad
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml"
convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout"
# commenting this test case out until image handling is fixed
#convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-image.yml"
convert::expect_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-ports.yml" "Service cannot be created because of missing port."
#convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-image.yml convert --stdout"
convert::expect_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-ports.yml convert --stdout" "Service cannot be created because of missing port."
export $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs)
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-k8s.json" "Unsupported key depends_on - ignoring"
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-k8s.json" "Unsupported key depends_on - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-os.json" "Unsupported key depends_on - ignoring"
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/etherpad/output-os.json" "Unsupported key depends_on - ignoring"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs | cut -d'=' -f1)
######
# Tests related to docker-compose file in /script/test/fixtures/gitlab
convert::expect_failure "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml"
convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout"
export $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs)
# kubernetes test
convert::expect_success "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-k8s.json"
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-k8s.json"
# openshift test
convert::expect_success "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-os.json"
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/gitlab/output-os.json"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1)
######
# Tests related to docker-compose file in /script/test/fixtures/ngnix-node-redis
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-k8s.json" "Unsupported key build - ignoring"
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-k8s.json" "Unsupported key build - ignoring"
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-os.json" "Unsupported key build - ignoring"
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-os.json" "Unsupported key build - ignoring"
######
# Tests related to docker-compose file in /script/test/fixtures/entrypoint-command
# kubernetes test
convert::expect_success_and_warning "kompose convert --stdout -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json" "Service cannot be created because of missing port."
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json" "Service cannot be created because of missing port."
# openshift test
convert::expect_success_and_warning "kompose convert --stdout --dc -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os.json" "Service cannot be created because of missing port."
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os.json" "Service cannot be created because of missing port."
exit $EXIT_STATUS