MCPcopy Index your code
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / instanceFromEnv

Function instanceFromEnv

cmd/root.go:726–752  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

724}
725
726func 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
754func instanceFromConfigFile(v *viper.Viper) []string {
755 var args []string

Callers 1

loadConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected