Skip to content

Commit 8dcdc43

Browse files
simt2Joshua Dotson
authored and
Joshua Dotson
committed
Add top-level targetContext for backwards compatibility
1 parent 95c658a commit 8dcdc43

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cmd/helpers.go

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ func unmarshalConfig(logger *logrus.Entry) lib.MHConfigFile {
5050
if err := viper.Unmarshal(&mhConfigFile); err != nil {
5151
logger.WithField("error", err).Fatal("Failed to unmarshal mh configuration file")
5252
}
53+
54+
// Check top-level targetContext for backwards compatibility
55+
if mhConfigFile.TargetContext != "" {
56+
logger.Warn("Top-level configuration is deprecated, move to the 'mh' key")
57+
mhConfigFile.MH.TargetContext = mhConfigFile.TargetContext
58+
}
59+
5360
logger = logger.WithField("configFile", viper.ConfigFileUsed())
5461

5562
return mhConfigFile

mhlib/mhConfigFile.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ import (
2222

2323
// MHConfigFile is the structure of a mh configuration file.
2424
type MHConfigFile struct {
25-
MH MHConfig `yaml:"mh"`
26-
Apps AppConfigs `yaml:"apps"`
27-
AppSources AppSourceConfigs `yaml:"appSources"`
25+
// TargetContext for backwards compatibility
26+
TargetContext string `yaml:"targetContext"`
27+
MH MHConfig `yaml:"mh"`
28+
Apps AppConfigs `yaml:"apps"`
29+
AppSources AppSourceConfigs `yaml:"appSources"`
2830
}
2931

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

0 commit comments

Comments
 (0)