func()

in internal/cloudsql/instance.go [212:236]


func (c ConnectionInfo) Addr(ipType string) (string, error) {
	var (
		addr string
		ok   bool
	)
	switch ipType {
	case AutoIP:
		// Try Public first
		addr, ok = c.addrs[PublicIP]
		if !ok {
			// Try Private second
			addr, ok = c.addrs[PrivateIP]
		}
	default:
		addr, ok = c.addrs[ipType]
	}
	if !ok {
		err := errtype.NewConfigError(
			fmt.Sprintf("instance does not have IP of type %q", ipType),
			c.ConnectionName.String(),
		)
		return "", err
	}
	return addr, nil
}