// GetNewRC returns an RC that matches the intent of the given deployment; get RCList from client interface.
// Returns nil if the new RC doesnt exist yet.
185300
func GetNewRC(deployment extensions.Deployment, c client.Interface) (*api.ReplicationController, error) {
	return GetNewRCFromList(deployment, c,
		func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
			rcList, err := c.ReplicationControllers(namespace).List(options)
			return rcList.Items, err
		})
}
560155
func LoggerNewRequest(ctx context.Context) context.Context {
	u, _ := uuid.NewUUID()
	uStr := u.String()
	ctx = context.WithValue(ctx, RequestUuidKey, uStr)
	return ctx
}
292815
func getNextMiddleware(mids []Middleware, h http.Handler) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		if len(mids) > 0 {
			mids[0].ServeHTTPMiddleware(w, r, getNextMiddleware(mids[1:], h))
		} else {
			h.ServeHTTP(w, r)
		}
	}
}
441145
func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, repo string, sha string, opt RawOptions) (string, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha)
	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return "", nil, err
	}

	switch opt.Type {
	case Diff:
		req.Header.Set("Accept", mediaTypeV3Diff)
	case Patch:
		req.Header.Set("Accept", mediaTypeV3Patch)
	default:
		return "", nil, fmt.Errorf("unsupported raw type %d", opt.Type)
	}

	var buf bytes.Buffer
	resp, err := s.client.Do(ctx, req, &buf)
	if err != nil {
		return "", resp, err
	}

	return buf.String(), resp, nil
}
202113
func (r *RPCWrapper) GetRPCClient(contextID string) (*RPCHdl, error) {

	r.Lock()
	defer r.Unlock()

	val, err := r.rpcClientMap.Get(contextID)
	if err != nil {
		return nil, err
	}

	return val.(*RPCHdl), nil
}
508735
func (r *RPCWrapper) NewRPCClient(contextID string, channel string, sharedsecret string) error {

	r.Lock()
	defer r.Unlock()

	max := maxRetries
	retries := os.Getenv(envRetryString)
	if len(retries) > 0 {
		max, _ = strconv.Atoi(retries)
	}

	numRetries := 0
	client, err := rpc.DialHTTP("unix", channel)
	for err != nil {
		numRetries++
		if numRetries >= max {
			return err
		}

		time.Sleep(5 * time.Millisecond)
		client, err = rpc.DialHTTP("unix", channel)
	}

	r.rpcClientMap.AddOrUpdate(contextID, &RPCHdl{Client: client, Channel: channel, Secret: sharedsecret})

	return nil

}
443168
func (d *Deployment) GetRef() string {
	if d == nil || d.Ref == nil {
		return ""
	}
	return *d.Ref
}
770602
func GetNewEnvironFunc(newEnviron environs.NewEnvironFunc) NewEnvironFunc {
	return func(st *state.State) (environs.Environ, error) {
		m, err := st.Model()
		if err != nil {
			return nil, errors.Trace(err)
		}
		g := EnvironConfigGetter{State: st, Model: m}
		return environs.GetEnviron(g, newEnviron)
	}
}
1127698
func (w *deploymentWatcher) getAllocsImpl(ws memdb.WatchSet, state *state.StateStore) (interface{}, uint64, error) {
	if err := w.queryLimiter.Wait(w.ctx); err != nil {
		return nil, 0, err
	}

	// Capture all the allocations
	allocs, err := state.AllocsByDeployment(ws, w.deploymentID)
	if err != nil {
		return nil, 0, err
	}

	maxIndex := uint64(0)
	stubs := make([]*structs.AllocListStub, 0, len(allocs))
	for _, alloc := range allocs {
		stubs = append(stubs, alloc.Stub())

		if maxIndex < alloc.ModifyIndex {
			maxIndex = alloc.ModifyIndex
		}
	}

	// Use the last index that affected the allocs table
	if len(stubs) == 0 {
		index, err := state.Index("allocs")
		if err != nil {
			return nil, index, err
		}
		maxIndex = index
	}

	return stubs, maxIndex, nil
}
1120118
func GetRCSBackend(ctx context.Context) RCSBackend {
	be, ok := ctx.Value(ctxKeyRCSBackend).(RCSBackend)
	if !ok {
		return Noop
	}
	return be
}
616626
func (dc *DeploymentController) getDeploymentsForReplicaSet(rs *apps.ReplicaSet) []*apps.Deployment {
	deployments, err := dc.dLister.GetDeploymentsForReplicaSet(rs)
	if err != nil || len(deployments) == 0 {
		return nil
	}
	// Because all ReplicaSet's belonging to a deployment should have a unique label key,
	// there should never be more than one deployment returned by the above method.
	// If that happens we should probably dynamically repair the situation by ultimately
	// trying to clean up one of the controllers, for now we just return the older one
	if len(deployments) > 1 {
		// ControllerRef will ensure we don't do anything crazy, but more than one
		// item in this list nevertheless constitutes user error.
		klog.V(4).Infof("user error! more than one deployment is selecting replica set %s/%s with labels: %#v, returning %s/%s",
			rs.Namespace, rs.Name, rs.Labels, deployments[0].Namespace, deployments[0].Name)
	}
	return deployments
}
798576
func (obj *Variable) GetNxPropertiesRaw(ctx context.Context) (json.RawMessage, error) {
	result := &struct {
		Properties json.RawMessage	`json:"qProperties"`
	} {}
	err := obj.rpc(ctx, "GetNxProperties", result)
	return result.Properties, err 
}
1209187
func GetRawBuild(c context.Context, address string) (*bbv1.ApiCommonBuildMessage, error) {
	host, err := getHost(c)
	if err != nil {
		return nil, err
	}

	client, err := newBuildbucketClient(c, host)
	if err != nil {
		return nil, err
	}
	// This runs a search RPC against BuildBucket, but it is optimized for speed.
	build, err := bbv1.GetByAddress(c, client, address)
	switch {
	case err != nil:
		return nil, errors.Annotate(err, "could not get build at %q", address).Err()
	case build == nil && auth.CurrentUser(c).Identity == identity.AnonymousIdentity:
		return nil, errors.Reason("not logged in").Tag(grpcutil.UnauthenticatedTag).Err()
	case build == nil:
		return nil, errors.Reason("build at %q not found", address).Tag(grpcutil.NotFoundTag).Err()
	default:
		return build, nil
	}
}
1136532
func (c *Context) GetNextURL(allowReferer ...bool) string {
	next := c.Header(`X-Next`)
	if len(next) == 0 {
		next = c.Form(`next`)
	}
	if len(next) > 0 {
		return c.ParseNextURL(next)
	}
	if len(allowReferer) < 1 || allowReferer[0] {
		next = c.Referer()
		if len(next) == 0 || !strings.HasSuffix(next, c.Request().URI()) {
			return next
		}
	}
	return ``
}
1010677
func (p *ConnPool) getNewConn(dc string, addr net.Addr, version int, useTLS bool) (*Conn, error) {
	// Get a new, raw connection.
	conn, _, err := p.DialTimeout(dc, addr, defaultDialTimeout, useTLS)
	if err != nil {
		return nil, err
	}

	// Switch the multiplexing based on version
	var session muxSession
	if version < 2 {
		conn.Close()
		return nil, fmt.Errorf("cannot make client connection, unsupported protocol version %d", version)
	}

	// Write the Consul multiplex byte to set the mode
	if _, err := conn.Write([]byte{byte(RPCMultiplexV2)}); err != nil {
		conn.Close()
		return nil, err
	}

	// Setup the logger
	conf := yamux.DefaultConfig()
	conf.LogOutput = p.LogOutput

	// Create a multiplexed session
	session, _ = yamux.Client(conn, conf)

	// Wrap the connection
	c := &Conn{
		refCount: 1,
		addr:     addr,
		session:  session,
		clients:  list.New(),
		lastUsed: time.Now(),
		version:  version,
		pool:     p,
	}
	return c, nil
}
339761
func (d *deviceAllocator) GetNext(existingDevices ExistingDevices) (mountDevice, error) {
	for _, devicePair := range d.sortByCount() {
		if _, found := existingDevices[devicePair.deviceName]; !found {
			return devicePair.deviceName, nil
		}
	}
	return "", fmt.Errorf("no devices are available")
}
339092
func (t *Template) GetAllAWSNeptuneDBClusterResources() map[string]*resources.AWSNeptuneDBCluster {
	results := map[string]*resources.AWSNeptuneDBCluster{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSNeptuneDBCluster:
			results[name] = resource
		}
	}
	return results
}