Merge pull request #817 from surajnarwade/vol_validation

Fixed `--volumes` validation
This commit is contained in:
Charlie Drage 2017-09-26 15:24:03 -04:00 committed by GitHub
commit d3df8d2009
2 changed files with 7 additions and 0 deletions

View File

@ -133,6 +133,10 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec
if opt.GenerateJSON && opt.GenerateYaml {
log.Fatalf("YAML and JSON format cannot be provided at the same time")
}
if opt.Volumes != "persistentVolumeClaim" && opt.Volumes != "emptyDir" {
log.Fatal("Unknown Volume type: ", opt.Volumes, ", possible values are: persistentVolumeClaim and emptyDir")
}
}
// ValidateComposeFile validated the compose file provided for conversion

View File

@ -374,6 +374,9 @@ cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/dock
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.json > /tmp/output-k8s.json
convert::expect_success_and_warning "kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml --stdout -j --volumes emptyDir" "/tmp/output-k8s.json" "Volume mount on the host "\"."\" isn't supported - ignoring path on the host"
#Failing test for `--volumes` option
convert::expect_failure "kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yaml --volumes foobar"
# Test related to support docker-compose.yaml beside docker-compose.yml
# Store the original path
CURRENT_DIR=$(pwd)