Example #1
0
func (c *Cmd) QueryOptions() *consulapi.QueryOptions {
	csl := c.consul

	queryOpts := new(consulapi.QueryOptions)
	if csl.token != "" {
		queryOpts.Token = csl.token
	}

	if csl.dc != "" {
		queryOpts.Datacenter = csl.dc
	}

	if csl.waitIndex != 0 {
		queryOpts.WaitIndex = csl.waitIndex
	}

	if csl.consistent {
		queryOpts.RequireConsistent = csl.consistent
	}

	if csl.stale {
		queryOpts.AllowStale = csl.stale
	}

	return queryOpts
}
Example #2
0
func (m *Meta) QueryOptions() *consulapi.QueryOptions {
	queryOpts := new(consulapi.QueryOptions)

	if os.Getenv("CONSUL_TOKEN") != "" {
		queryOpts.Token = os.Getenv("CONSUL_TOKEN")
	}

	if m.token != "" {
		queryOpts.Token = m.token
	}

	if m.dc != "" {
		queryOpts.Datacenter = m.dc
	}

	if m.waitIndex != 0 {
		queryOpts.WaitIndex = m.waitIndex
	}

	return queryOpts
}
Example #3
0
func (m *Meta) QueryOptions() *consulapi.QueryOptions {
	queryOpts := new(consulapi.QueryOptions)
	if m.token != "" {
		queryOpts.Token = m.token
	}

	if m.dc != "" {
		queryOpts.Datacenter = m.dc
	}

	if m.waitIndex != 0 {
		queryOpts.WaitIndex = m.waitIndex
	}

	return queryOpts
}