forked from LaconicNetwork/kompose
don't print warning to stdout #71
This commit is contained in:
parent
bc7705157a
commit
72fc1a2f42
@ -732,7 +732,7 @@ func loadImage(service bundlefile.Service) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load DAB file into KomposeObject
|
// Load DAB file into KomposeObject
|
||||||
func loadBundlesFile(file string) KomposeObject {
|
func loadBundlesFile(file string, opt convertOptions) KomposeObject {
|
||||||
komposeObject := KomposeObject{
|
komposeObject := KomposeObject{
|
||||||
ServiceConfigs: make(map[string]ServiceConfig),
|
ServiceConfigs: make(map[string]ServiceConfig),
|
||||||
}
|
}
|
||||||
@ -747,8 +747,9 @@ func loadBundlesFile(file string) KomposeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, service := range bundle.Services {
|
for name, service := range bundle.Services {
|
||||||
|
if !opt.toStdout {
|
||||||
checkUnsupportedKey(service)
|
checkUnsupportedKey(service)
|
||||||
|
}
|
||||||
serviceConfig := ServiceConfig{}
|
serviceConfig := ServiceConfig{}
|
||||||
serviceConfig.Command = service.Command
|
serviceConfig.Command = service.Command
|
||||||
serviceConfig.Args = service.Args
|
serviceConfig.Args = service.Args
|
||||||
@ -782,7 +783,7 @@ func loadBundlesFile(file string) KomposeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load compose file into KomposeObject
|
// Load compose file into KomposeObject
|
||||||
func loadComposeFile(file string) KomposeObject {
|
func loadComposeFile(file string, opt convertOptions) KomposeObject {
|
||||||
komposeObject := KomposeObject{
|
komposeObject := KomposeObject{
|
||||||
ServiceConfigs: make(map[string]ServiceConfig),
|
ServiceConfigs: make(map[string]ServiceConfig),
|
||||||
}
|
}
|
||||||
@ -822,8 +823,9 @@ func loadComposeFile(file string) KomposeObject {
|
|||||||
composeServiceNames := composeObject.ServiceConfigs.Keys()
|
composeServiceNames := composeObject.ServiceConfigs.Keys()
|
||||||
for _, name := range composeServiceNames {
|
for _, name := range composeServiceNames {
|
||||||
if composeServiceConfig, ok := composeObject.ServiceConfigs.Get(name); ok {
|
if composeServiceConfig, ok := composeObject.ServiceConfigs.Get(name); ok {
|
||||||
// TODO: mapping composeObject config to komposeObject config
|
if !opt.toStdout {
|
||||||
checkUnsupportedKey(composeServiceConfig)
|
checkUnsupportedKey(composeServiceConfig)
|
||||||
|
}
|
||||||
serviceConfig := ServiceConfig{}
|
serviceConfig := ServiceConfig{}
|
||||||
serviceConfig.Image = composeServiceConfig.Image
|
serviceConfig.Image = composeServiceConfig.Image
|
||||||
serviceConfig.ContainerName = composeServiceConfig.ContainerName
|
serviceConfig.ContainerName = composeServiceConfig.ContainerName
|
||||||
@ -896,9 +898,6 @@ func komposeConvert(komposeObject KomposeObject, opt convertOptions) {
|
|||||||
|
|
||||||
for name, service := range komposeObject.ServiceConfigs {
|
for name, service := range komposeObject.ServiceConfigs {
|
||||||
svcnames = append(svcnames, name)
|
svcnames = append(svcnames, name)
|
||||||
|
|
||||||
//checkUnsupportedKey(service)
|
|
||||||
|
|
||||||
rc := initRC(name, service, opt.replicas)
|
rc := initRC(name, service, opt.replicas)
|
||||||
sc := initSC(name, service)
|
sc := initSC(name, service)
|
||||||
dc := initDC(name, service, opt.replicas)
|
dc := initDC(name, service, opt.replicas)
|
||||||
@ -990,9 +989,9 @@ func komposeConvert(komposeObject KomposeObject, opt convertOptions) {
|
|||||||
|
|
||||||
var datasvc []byte
|
var datasvc []byte
|
||||||
// If ports not provided in configuration we will not make service
|
// If ports not provided in configuration we will not make service
|
||||||
if len(ports) == 0 {
|
if len(ports) == 0 && !opt.toStdout {
|
||||||
logrus.Warningf("[%s] Service cannot be created because of missing port.", name)
|
logrus.Warningf("[%s] Service cannot be created because of missing port.", name)
|
||||||
} else {
|
} else if len(ports) != 0 {
|
||||||
// convert datasvc to json / yaml
|
// convert datasvc to json / yaml
|
||||||
datasvc, err = transformer(sc, opt.generateYaml)
|
datasvc, err = transformer(sc, opt.generateYaml)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1110,14 +1109,6 @@ func Convert(c *cli.Context) {
|
|||||||
|
|
||||||
komposeObject := KomposeObject{}
|
komposeObject := KomposeObject{}
|
||||||
file := inputFile
|
file := inputFile
|
||||||
|
|
||||||
if len(dabFile) > 0 {
|
|
||||||
komposeObject = loadBundlesFile(dabFile)
|
|
||||||
file = dabFile
|
|
||||||
} else {
|
|
||||||
komposeObject = loadComposeFile(inputFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert komposeObject to K8S controllers
|
// Convert komposeObject to K8S controllers
|
||||||
opt := convertOptions{
|
opt := convertOptions{
|
||||||
toStdout: toStdout,
|
toStdout: toStdout,
|
||||||
@ -1131,6 +1122,14 @@ func Convert(c *cli.Context) {
|
|||||||
inputFile: file,
|
inputFile: file,
|
||||||
outFile: outFile,
|
outFile: outFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(dabFile) > 0 {
|
||||||
|
komposeObject = loadBundlesFile(dabFile, opt)
|
||||||
|
file = dabFile
|
||||||
|
} else {
|
||||||
|
komposeObject = loadComposeFile(inputFile, opt)
|
||||||
|
}
|
||||||
|
|
||||||
komposeConvert(komposeObject, opt)
|
komposeConvert(komposeObject, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user