Skip to content

Commit

Permalink
don't print warning to stdout #71
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Aug 2, 2016
1 parent bc77051 commit 72fc1a2
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var unsupportedKey = map[string]int{
"Args": 0,
}

var composeOptions = map[string]string {
var composeOptions = map[string]string{
"Build": "build",
"CapAdd": "cap_add",
"CapDrop": "cap_drop",
Expand Down Expand Up @@ -732,7 +732,7 @@ func loadImage(service bundlefile.Service) (string, string) {
}

// Load DAB file into KomposeObject
func loadBundlesFile(file string) KomposeObject {
func loadBundlesFile(file string, opt convertOptions) KomposeObject {
komposeObject := KomposeObject{
ServiceConfigs: make(map[string]ServiceConfig),
}
Expand All @@ -747,8 +747,9 @@ func loadBundlesFile(file string) KomposeObject {
}

for name, service := range bundle.Services {
checkUnsupportedKey(service)

if !opt.toStdout {
checkUnsupportedKey(service)
}
serviceConfig := ServiceConfig{}
serviceConfig.Command = service.Command
serviceConfig.Args = service.Args
Expand Down Expand Up @@ -782,7 +783,7 @@ func loadBundlesFile(file string) KomposeObject {
}

// Load compose file into KomposeObject
func loadComposeFile(file string) KomposeObject {
func loadComposeFile(file string, opt convertOptions) KomposeObject {
komposeObject := KomposeObject{
ServiceConfigs: make(map[string]ServiceConfig),
}
Expand Down Expand Up @@ -822,8 +823,9 @@ func loadComposeFile(file string) KomposeObject {
composeServiceNames := composeObject.ServiceConfigs.Keys()
for _, name := range composeServiceNames {
if composeServiceConfig, ok := composeObject.ServiceConfigs.Get(name); ok {
// TODO: mapping composeObject config to komposeObject config
checkUnsupportedKey(composeServiceConfig)
if !opt.toStdout {
checkUnsupportedKey(composeServiceConfig)
}
serviceConfig := ServiceConfig{}
serviceConfig.Image = composeServiceConfig.Image
serviceConfig.ContainerName = composeServiceConfig.ContainerName
Expand Down Expand Up @@ -896,9 +898,6 @@ func komposeConvert(komposeObject KomposeObject, opt convertOptions) {

for name, service := range komposeObject.ServiceConfigs {
svcnames = append(svcnames, name)

//checkUnsupportedKey(service)

rc := initRC(name, service, opt.replicas)
sc := initSC(name, service)
dc := initDC(name, service, opt.replicas)
Expand Down Expand Up @@ -990,9 +989,9 @@ func komposeConvert(komposeObject KomposeObject, opt convertOptions) {

var datasvc []byte
// 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)
} else {
} else if len(ports) != 0 {
// convert datasvc to json / yaml
datasvc, err = transformer(sc, opt.generateYaml)
if err != nil {
Expand Down Expand Up @@ -1110,14 +1109,6 @@ func Convert(c *cli.Context) {

komposeObject := KomposeObject{}
file := inputFile

if len(dabFile) > 0 {
komposeObject = loadBundlesFile(dabFile)
file = dabFile
} else {
komposeObject = loadComposeFile(inputFile)
}

// Convert komposeObject to K8S controllers
opt := convertOptions{
toStdout: toStdout,
Expand All @@ -1131,6 +1122,14 @@ func Convert(c *cli.Context) {
inputFile: file,
outFile: outFile,
}

if len(dabFile) > 0 {
komposeObject = loadBundlesFile(dabFile, opt)
file = dabFile
} else {
komposeObject = loadComposeFile(inputFile, opt)
}

komposeConvert(komposeObject, opt)
}

Expand Down

0 comments on commit 72fc1a2

Please sign in to comment.