error out if controller object is specified with "restart: on-failure"

This commit is contained in:
Abhishek
2017-01-30 17:52:36 +05:30
parent abad9b1beb
commit 1ecd32a362
6 changed files with 48 additions and 67 deletions
+19 -15
View File
@@ -29,21 +29,25 @@ type KomposeObject struct {
// ConvertOptions holds all options that controls transformation process
type ConvertOptions struct {
ToStdout bool
CreateD bool
CreateRC bool
CreateDS bool
CreateDeploymentConfig bool
BuildRepo string
BuildBranch string
CreateChart bool
GenerateYaml bool
GenerateJSON bool
EmptyVols bool
Replicas int
InputFiles []string
OutFile string
Provider string
ToStdout bool
CreateD bool
CreateRC bool
CreateDS bool
CreateDeploymentConfig bool
BuildRepo string
BuildBranch string
CreateChart bool
GenerateYaml bool
GenerateJSON bool
EmptyVols bool
Replicas int
InputFiles []string
OutFile string
Provider string
IsDeploymentFlag bool
IsDaemonSetFlag bool
IsReplicationControllerFlag bool
IsDeploymentConfigFlag bool
}
// ServiceConfig holds the basic struct of a container
+4
View File
@@ -468,6 +468,10 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
// Generate pod only and nothing more
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)
objects = append(objects, pod)
} else {
+4
View File
@@ -321,6 +321,10 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
// Generate pod only and nothing more
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)
objects = append(objects, pod)
} else {