forked from LaconicNetwork/kompose
Merge pull request #373 from procrypt/error_should_be_displayed
error out if controller object is specified with "restart: on-failure"
This commit is contained in:
commit
2f05ecdcf0
@ -70,6 +70,10 @@ var convertCmd = &cobra.Command{
|
|||||||
BuildBranch: ConvertBuildBranch,
|
BuildBranch: ConvertBuildBranch,
|
||||||
CreateDeploymentConfig: ConvertDeploymentConfig,
|
CreateDeploymentConfig: ConvertDeploymentConfig,
|
||||||
EmptyVols: ConvertEmptyVols,
|
EmptyVols: ConvertEmptyVols,
|
||||||
|
IsDeploymentFlag: cmd.Flags().Lookup("deployment").Changed,
|
||||||
|
IsDaemonSetFlag: cmd.Flags().Lookup("daemon-set").Changed,
|
||||||
|
IsReplicationControllerFlag: cmd.Flags().Lookup("replication-controller").Changed,
|
||||||
|
IsDeploymentConfigFlag: cmd.Flags().Lookup("deployment-config").Changed,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate before doing anything else. Use "bundle" if passed in.
|
// Validate before doing anything else. Use "bundle" if passed in.
|
||||||
|
|||||||
@ -44,6 +44,10 @@ type ConvertOptions struct {
|
|||||||
InputFiles []string
|
InputFiles []string
|
||||||
OutFile string
|
OutFile string
|
||||||
Provider string
|
Provider string
|
||||||
|
IsDeploymentFlag bool
|
||||||
|
IsDaemonSetFlag bool
|
||||||
|
IsReplicationControllerFlag bool
|
||||||
|
IsDeploymentConfigFlag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceConfig holds the basic struct of a container
|
// ServiceConfig holds the basic struct of a container
|
||||||
|
|||||||
@ -468,6 +468,10 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
|
|
||||||
// Generate pod only and nothing more
|
// Generate pod only and nothing more
|
||||||
if service.Restart == "no" || service.Restart == "on-failure" {
|
if service.Restart == "no" || service.Restart == "on-failure" {
|
||||||
|
// Error out if Controller Object is specified with restart: 'on-failure'
|
||||||
|
if opt.IsDeploymentFlag || opt.IsDaemonSetFlag || opt.IsReplicationControllerFlag {
|
||||||
|
logrus.Fatalf("Controller object cannot be specified with restart: 'on-failure'")
|
||||||
|
}
|
||||||
pod := k.InitPod(name, service)
|
pod := k.InitPod(name, service)
|
||||||
objects = append(objects, pod)
|
objects = append(objects, pod)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -321,6 +321,10 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
|
|||||||
|
|
||||||
// Generate pod only and nothing more
|
// Generate pod only and nothing more
|
||||||
if service.Restart == "no" || service.Restart == "on-failure" {
|
if service.Restart == "no" || service.Restart == "on-failure" {
|
||||||
|
// Error out if Controller Object is specified with restart: 'on-failure'
|
||||||
|
if opt.IsDeploymentConfigFlag {
|
||||||
|
logrus.Fatalf("Controller object cannot be specified with restart: 'on-failure'")
|
||||||
|
}
|
||||||
pod := o.InitPod(name, service)
|
pod := o.InitPod(name, service)
|
||||||
objects = append(objects, pod)
|
objects = append(objects, pod)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -110,10 +110,10 @@ convert::expect_success_and_warning "kompose --bundle $KOMPOSE_ROOT/script/test/
|
|||||||
# Test related to restart options in docker-compose
|
# Test related to restart options in docker-compose
|
||||||
# kubernetes test
|
# kubernetes test
|
||||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-no.json"
|
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-no.json"
|
||||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-onfail.json"
|
convert::failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" "Controller object cannot be specified with restart: 'on-failure'"
|
||||||
# openshift test
|
# openshift test
|
||||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml --provider openshift convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-no.json"
|
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml --provider openshift convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-no.json"
|
||||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-onfail.json"
|
convert::failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout -j" "Controller object cannot be specified with restart: 'on-failure'"
|
||||||
|
|
||||||
|
|
||||||
######
|
######
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"kind": "List",
|
|
||||||
"apiVersion": "v1",
|
|
||||||
"metadata": {},
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"kind": "Pod",
|
|
||||||
"apiVersion": "v1",
|
|
||||||
"metadata": {
|
|
||||||
"name": "foo",
|
|
||||||
"creationTimestamp": null,
|
|
||||||
"labels": {
|
|
||||||
"service": "foo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"spec": {
|
|
||||||
"containers": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"image": "foobar",
|
|
||||||
"env": [
|
|
||||||
{
|
|
||||||
"name": "GITHUB",
|
|
||||||
"value": "surajssd"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"resources": {}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"restartPolicy": "OnFailure"
|
|
||||||
},
|
|
||||||
"status": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user