Skip to content

Commit

Permalink
Merge pull request #90 from ngtuna/unsupported-keys
Browse files Browse the repository at this point in the history
enhance warning: networks, network config, volume config. Fixes #88, #71
  • Loading branch information
ngtuna authored Aug 10, 2016
2 parents 3da3fb5 + 908a256 commit 14cf356
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,25 @@ func loadComposeFile(file string) KomposeObject {

// transform composeObject into komposeObject
composeServiceNames := composeObject.ServiceConfigs.Keys()

// volume config and network config are not supported
if len(composeObject.NetworkConfigs) > 0 {
logrus.Warningf("Unsupported network configuration of compose v2 - ignoring")
}
if len(composeObject.VolumeConfigs) > 0 {
logrus.Warningf("Unsupported volume configuration of compose v2 - ignoring")
}

networksWarningFound := false
for _, name := range composeServiceNames {
if composeServiceConfig, ok := composeObject.ServiceConfigs.Get(name); ok {
//FIXME: networks always contains one default element, even it isn't declared in compose v2.
if len(composeServiceConfig.Networks.Networks) > 0 &&
composeServiceConfig.Networks.Networks[0].Name != "default" &&
!networksWarningFound {
logrus.Warningf("Unsupported key networks - ignoring")
networksWarningFound = true
}
checkUnsupportedKey(composeServiceConfig)
serviceConfig := ServiceConfig{}
serviceConfig.Image = composeServiceConfig.Image
Expand Down Expand Up @@ -1179,9 +1196,9 @@ func Convert(c *cli.Context) {
func checkUnsupportedKey(service interface{}) {
s := structs.New(service)
for _, f := range s.Fields() {
if f.IsExported() && !f.IsZero() {
if f.IsExported() && !f.IsZero() && f.Name() != "Networks" {
if count, ok := unsupportedKey[f.Name()]; ok && count == 0 {
logrus.Warningf("Unsupported key " + composeOptions[f.Name()] + " - ignoring")
logrus.Warningf("Unsupported key %s - ignoring", composeOptions[f.Name()])
unsupportedKey[f.Name()]++
}
}
Expand Down

0 comments on commit 14cf356

Please sign in to comment.