// GetMaster returns the default macro and its parameter type,
// by default it will return the `String` macro which is responsible for the "string" parameter type.
13439
func (ms *Macros) GetMaster() *Macro {
	for _, m := range *ms {
		if m.Master() {
			return m
		}
	}

	return nil
}
125408
func (dg *discoveryGateway) GetMasterCell(keyspace, shard string) (string, queryservice.QueryService, error) {
	cell, err := dg.tsc.GetMasterCell(keyspace, shard)
	return cell, dg, err
}
576628
func GetLevel(c context.Context) Level {
	if l, ok := c.Value(levelKey).(Level); ok {
		return l
	}
	return DefaultLevel
}
646748
func (m *Manager) GetAccessToken(token string) (at *AccessToken, err error) {
	at = &AccessToken{}

	err = m.getAccessTokenCollection().Find(bson.M{"accesstoken": token}).One(at)
	if err != nil && err == mgo.ErrNotFound {
		at = nil
		err = nil
		return
	}
	if err != nil {
		at = nil
		return
	}
	if at.IsExpired() {
		at = nil
		err = nil
	}

	return
}
1330152
func (cmd *Cmd) GetVar(k string) (string, bool) {
	return cmd.context.GetVar(k)
}
365444
func (extr *ContentExtractor) GetMetaContent(document *goquery.Document, metaName string) string {
	content := ""
	document.Find("meta").EachWithBreak(func(i int, s *goquery.Selection) bool {
		attr, exists := s.Attr("name")
		if exists && attr == metaName {
			content, _ = s.Attr("content")
			return false
		}
		attr, exists = s.Attr("itemprop")
		if exists && attr == metaName {
			content, _ = s.Attr("content")
			return false
		}
		return true
	})
	return content
}
480467
func (c *InstancesClient) GetMetadata(ctx context.Context, input *GetMetadataInput) (string, error) {
	if input.Key == "" {
		return "", fmt.Errorf("Missing metadata Key from input: %s", input.Key)
	}

	fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
	reqInputs := client.RequestInput{
		Method: http.MethodGet,
		Path:   fullPath,
	}
	response, err := c.client.ExecuteRequestRaw(ctx, reqInputs)
	if err != nil {
		return "", pkgerrors.Wrap(err, "unable to get machine metadata")
	}
	if response != nil {
		defer response.Body.Close()
	}
	if response.StatusCode == http.StatusNotFound || response.StatusCode == http.StatusGone {
		return "", &errors.APIError{
			StatusCode: response.StatusCode,
			Code:       "ResourceNotFound",
		}
	}

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return "", pkgerrors.Wrap(err, "unable to decode get machine metadata response")
	}

	return fmt.Sprintf("%s", body), nil
}
950375
func getOSInfo(c context.Context, b *buildbot.Build, m *buildstore.Master) (
	family, version string) {
	// Fetch the master info from datastore if not provided.
	if m.Name == "" {
		logging.Infof(c, "Fetching info for master %s", b.Master)
		freshMaster, err := buildstore.GetMaster(c, b.Master, false)
		if err != nil {
			logging.WithError(err).Errorf(c, "fetching master %q", b.Master)
			return
		}
		if freshMaster.Internal && !b.Internal {
			logging.Errorf(c, "Build references an internal master, but build is not internal.")
			return
		}
		*m = *freshMaster
	}

	s, ok := m.Slaves[b.Slave]
	if !ok {
		logging.Warningf(c, "Could not find slave %s in master %s", b.Slave, b.Master)
		return
	}
	hostInfo := map[string]string{}
	for _, v := range strings.Split(s.Host, "\n") {
		if info := strings.SplitN(v, ":", 2); len(info) == 2 {
			hostInfo[info[0]] = strings.TrimSpace(info[1])
		}
	}
	// Extract OS and OS Family
	if v, ok := hostInfo["os family"]; ok {
		family = v
	}
	if v, ok := hostInfo["os version"]; ok {
		version = v
	}
	return
}
891504
func GetParam(name string, r *http.Request, index ...int) string {
	if params := r.Context().Value(ParamsKey); params != nil {
		params := params.(Params)
		if name != "*" {
			name = ":" + name
		}
		if param := params[name]; param != nil {
			switch param := param.(type) {
			case []string:
				if len(index) > 0 {
					if index[0] < len(param) {
						return param[index[0]]
					}
					return ""
				}
				return param[0]
			default:
				return param.(string)
			}
		}
	}
	return ""
}
896949
func (m *Manager) Get(key string) interface{} {
	// ensure loaded
	if !m.loaded {
		err := m.load(false)
		if err != nil {
			panic(err)
		}
	}

	opt := m.options.Find(key)
	def := m.defaults.Find(key)
	if def == nil {
		return opt
	} else if opt == nil {
		return def
	} else if v, err := cast.TryToValue(opt, reflect.TypeOf(def)); err == nil {
		return v
	}
	return opt
}
1205245
func (meta Metadata) GetValueString(key string) string {
	return string(meta.GetValue(key))
}
745471
func (c *ServerContext) GetTerm() Terminal {
	c.RLock()
	defer c.RUnlock()

	return c.term
}
1108433
func (d *MasterDaemon) getMasterInfo() (map[string]interface{}, error) {
	info := make(map[string]interface{})

	// get local ip
	localIP, err := netutils.GetDefaultAddr()
	if err != nil {
		return nil, errors.New("error getting local IP address")
	}

	// get current holder of master lock
	leader := leaderLock.GetHolder()
	if leader == "" {
		return nil, errors.New("leader not found")
	}

	// Get all netplugin services
	srvList, err := d.objdbClient.GetService("netplugin")
	if err != nil {
		log.Errorf("Error getting netplugin nodes. Err: %v", err)
		return nil, err
	}

	// Add each node
	pluginNodes := []string{}
	for _, srv := range srvList {
		pluginNodes = append(pluginNodes, srv.HostAddr)
	}

	// Get all netmaster services
	srvList, err = d.objdbClient.GetService("netmaster")
	if err != nil {
		log.Errorf("Error getting netmaster nodes. Err: %v", err)
		return nil, err
	}

	// Add each node
	masterNodes := []string{}
	for _, srv := range srvList {
		masterNodes = append(masterNodes, srv.HostAddr)
	}

	// setup info map
	info["local-ip"] = localIP
	info["leader-ip"] = leader
	info["current-state"] = d.currState
	info["netplugin-nodes"] = pluginNodes
	info["netmaster-nodes"] = masterNodes

	return info, nil
}
130465
func (c *Comandante) getCommand(cmdName string) *Command {
	for _, cmd := range c.registeredCommands {
		if cmdName == cmd.Name {
			return cmd
		}
	}

	return nil
}
61493
func getPluginCommand() *cli.Command {
	return &cli.Command{
		Name:     GetPluginCommandName,
		Usage:    GetPluginCommandUsage,
		Category: "Plugins",
		Action:   ActionWrapper(getPluginAction),
		Flags: []cli.Flag{
			cli.StringFlag{Name: "name"},
		},
	}
}
907600
func GetMasterStatus(endpoint string) (MasterStatus, error) {
	var dataSet []map[string]string
	var err error
	var result MasterStatus
	if dataSet, err = readDataSet(endpoint, "SHOW MASTER STATUS"); err == nil {
		// There should be exactly one row in the resultset of "SHOW MASTER STATUS"
		result.File = dataSet[0]["File"]
		result.Position = getInt(dataSet[0]["Position"])
		result.ExecutedGtidSet = dataSet[0]["Executed_Gtid_Set"]
		result.BinlogDoDB = dataSet[0]["Binlog_Do_DB"]
		result.BinlogIgnoreDB = dataSet[0]["Binlog_Ignore_DB"]
	}
	return result, err
}
1150285
func getMasterLockHolder() (string, error) {
	// Create the lock
	leaderLock, err := ObjdbClient.NewLock("netmaster/leader", "", 0)
	if err != nil {
		log.Fatalf("Could not create leader lock. Err: %v", err)
	}

	// get current holder of leader lock
	masterNode := leaderLock.GetHolder()
	if masterNode == "" {
		log.Errorf("No leader node found")
		return "", errors.New("no leader node")
	}

	return masterNode, nil
}