Exemple #1
0
func executeWithExistingConfig() {
	envName := findEnvNameFromArgs()

	if envName == "" {
		if _, single := configFile.DetermineIfServiceIsRooted(); single {
			envName = configFile.GetEnvironments()[0]
		} else {
			if configFile.DefaultEnv != "" {
				envName = configFile.DefaultEnv
			} else {
				rootCmd.Execute()
				logger.Logger().Error("Multiple environments are defined in config.  You must execute with -e envname.")
				printValidEnvironments()
				return
			}
		}
	}

	if _, err := configFile.GetEnvironment(envName); err != nil {
		logger.Logger().Error("'%s' environment could not be found in config (%s)\n\n", envName, configFile.Filename())
		printValidEnvironments()
		os.Exit(1)
	} else {
		viper.Set(ViperEnv, envName)
		if configFile.RootService {
			marathon.AddJailedMarathonToCmd(rootCmd, configFile)
		} else {
			marathon.AddMarathonToCmd(rootCmd, configFile)
		}
	}
	rootCmd.AddCommand(configCmd)
	rootCmd.Execute()
}
Exemple #2
0
func executeWithExistingConfig() {
	envName := determineEnvironment()
	if envName == "" {
		os.Exit(1)
	}
	if _, err := configFile.GetEnvironment(envName); err != nil {
		logger.Logger().Error("'%s' environment could not be found in config (%s)\n\n", envName, configFile.Filename())
		printValidEnvironments()
		os.Exit(1)
	} else {
		viper.Set(ViperEnv, envName)
		if configFile.RootService {
			marathon.AddJailedMarathonToCmd(rootCmd, configFile)
		} else {
			marathon.AddMarathonToCmd(rootCmd, configFile)
		}
	}
	compose.AddComposeToCmd(rootCmd, nil)
	rootCmd.AddCommand(configCmd)
	rootCmd.Execute()
}