// setGivenEnv takes the given env name and finds it in the env list // in the given settings object. It then populates the EnvironmentID and // ServiceID on the settings object with appropriate values. func setGivenEnv(envName string, settings *models.Settings) { for eName, e := range settings.Environments { if eName == envName { settings.EnvironmentID = e.EnvironmentID settings.ServiceID = e.ServiceID settings.EnvironmentName = envName } } }
// setFirstAssociatedEnv is the last line of defense. If no other environments // were found locally or from the default flag, then the first one in the list // of environments in the given settings object is used to populate // EnvironmentID and ServiceID with appropriate values. func setFirstAssociatedEnv(required bool, promptForEnv bool, settings *models.Settings) { for envName, e := range settings.Environments { settings.EnvironmentID = e.EnvironmentID settings.ServiceID = e.ServiceID settings.EnvironmentName = e.Name if promptForEnv { defaultEnvPrompt(envName) } break } }