Skip to content

Commit

Permalink
Add top-level targetContext for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
simt2 authored and Joshua Dotson committed Jul 13, 2018
1 parent 95c658a commit 8dcdc43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ func unmarshalConfig(logger *logrus.Entry) lib.MHConfigFile {
if err := viper.Unmarshal(&mhConfigFile); err != nil {
logger.WithField("error", err).Fatal("Failed to unmarshal mh configuration file")
}

// Check top-level targetContext for backwards compatibility
if mhConfigFile.TargetContext != "" {
logger.Warn("Top-level configuration is deprecated, move to the 'mh' key")
mhConfigFile.MH.TargetContext = mhConfigFile.TargetContext
}

logger = logger.WithField("configFile", viper.ConfigFileUsed())

return mhConfigFile
Expand Down
8 changes: 5 additions & 3 deletions mhlib/mhConfigFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import (

// MHConfigFile is the structure of a mh configuration file.
type MHConfigFile struct {
MH MHConfig `yaml:"mh"`
Apps AppConfigs `yaml:"apps"`
AppSources AppSourceConfigs `yaml:"appSources"`
// TargetContext for backwards compatibility
TargetContext string `yaml:"targetContext"`
MH MHConfig `yaml:"mh"`
Apps AppConfigs `yaml:"apps"`
AppSources AppSourceConfigs `yaml:"appSources"`
}

// EffectiveApps returns all Apps that are configured in a MHConfigFile,
Expand Down

0 comments on commit 8dcdc43

Please sign in to comment.