| 724 | } |
| 725 | |
| 726 | func instanceFromEnv(args []string) []string { |
| 727 | // This supports naming the first instance first with: |
| 728 | // INSTANCE_CONNECTION_NAME |
| 729 | // or if that's not defined, with: |
| 730 | // INSTANCE_CONNECTION_NAME_0 |
| 731 | inst := os.Getenv(fmt.Sprintf("%s_INSTANCE_CONNECTION_NAME", envPrefix)) |
| 732 | if inst == "" { |
| 733 | inst = os.Getenv(fmt.Sprintf("%s_INSTANCE_CONNECTION_NAME_0", envPrefix)) |
| 734 | if inst == "" { |
| 735 | return nil |
| 736 | } |
| 737 | } |
| 738 | args = append(args, inst) |
| 739 | |
| 740 | i := 1 |
| 741 | for { |
| 742 | instN := os.Getenv(fmt.Sprintf("%s_INSTANCE_CONNECTION_NAME_%d", envPrefix, i)) |
| 743 | // if the next instance connection name is not defined, stop checking |
| 744 | // environment variables. |
| 745 | if instN == "" { |
| 746 | break |
| 747 | } |
| 748 | args = append(args, instN) |
| 749 | i++ |
| 750 | } |
| 751 | return args |
| 752 | } |
| 753 | |
| 754 | func instanceFromConfigFile(v *viper.Viper) []string { |
| 755 | var args []string |