// GetClusterFromLease takes a lease and will find the appropriate cluster
330588
func GetClusterFromLease(lease *leases.Lease, clusterLister ClusterLister, projID, zone string) (*container.Cluster, error) {
	clusterMap, err := ParseMapFromGKE(clusterLister, projID, zone)
	if err != nil {
		return nil, err
	}
	cl, exists := clusterMap.ClusterByName(lease.ClusterName)
	if !exists {
		return nil, errNoSuchCluster{name: lease.ClusterName}
	}

	return cl, nil
}
1229779
func (a *AuthServer) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) {
	return a.GetCache().GetClusterConfig(opts...)
}
261900
func NewLease(clusterName string, exprTime time.Time) *Lease {
	return &Lease{
		ClusterName:         clusterName,
		LeaseExpirationTime: exprTime.Format(TimeFormat),
	}
}
168801
func (c *RESTClientset) GetCluster(name string) (*kops.Cluster, error) {
	namespace := restNamespaceForClusterName(name)
	return c.KopsClient.Clusters(namespace).Get(name, metav1.GetOptions{})
}
1101941
func (a AuthorizerAdapter) GetClusterRole(name string) (*rbacv1.ClusterRole, error) {
	return a.Registry.GetClusterRole(genericapirequest.NewContext(), name, &metav1.GetOptions{})
}
1154667
func (s *ClusterService) GetClusterByID(id string, opts ...OptionFunc) (*Cluster, int, error) {
	p := &ListClustersParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListClusters(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.Clusters[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for Cluster UUID: %s!", id)
}
1040273
func GetNodeCluster(uuid string) (NodeCluster, error) {

	url := ""
	if string(uuid[0]) == "/" {
		url = uuid[8:] + "/"
	} else {
		url = "nodecluster/" + uuid + "/"
	}

	request := "GET"
	//Empty Body Request
	body := []byte(`{}`)
	var response NodeCluster

	data, err := TutumCall(url, request, body)
	if err != nil {
		return response, err
	}

	err = json.Unmarshal(data, &response)
	if err != nil {
		return response, err
	}

	return response, nil
}
272984
func (s *Scheduler) GetClusterOperationDetails(ctx context.Context, req *automationpb.GetClusterOperationDetailsRequest) (*automationpb.GetClusterOperationDetailsResponse, error) {
	clusterOp, err := s.findClusterOp(req.Id)
	if err != nil {
		return nil, err
	}
	return &automationpb.GetClusterOperationDetailsResponse{
		ClusterOp: &clusterOp.ClusterOperation,
	}, nil
}
847673
func (_class ClusterHostClass) GetCluster(sessionID SessionRef, self ClusterHostRef) (_retval ClusterRef, _err error) {
	_method := "Cluster_host.get_cluster"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertClusterHostRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertClusterRefToGo(_method + " -> ", _result.Value)
	return
}
285839
func (s *ClusterPairServer) GetToken(
	ctx context.Context,
	req *api.SdkClusterPairGetTokenRequest,
) (*api.SdkClusterPairGetTokenResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	// Check if admin user - only system.admin can get cluster pair tokens
	if userInfo, ok := auth.NewUserInfoFromContext(ctx); ok {
		o := api.Ownership{}
		if !o.IsAdminByUser(userInfo) {
			return nil, status.Error(codes.Unauthenticated, "Must be system admin to get pair token")
		}
	}

	resp, err := s.cluster().GetPairToken(false)
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Cannot generate token: %v", err)
	}
	return &api.SdkClusterPairGetTokenResponse{
		Result: resp,
	}, nil
}
212559
func findUnusuedClusterByName(clusterMap *Map, leaseMap *leases.Map, clusterRegex string) (*containerservice.ContainerService, error) {
	regex, err := regexp.Compile(clusterRegex)
	if err != nil {
		return nil, err
	}
	for _, clusterName := range clusterMap.Names() {
		if regex.MatchString(clusterName) {
			cluster, err := checkLease(clusterMap, leaseMap, clusterName)
			if err == nil {
				return cluster, nil
			}
		}
	}
	return nil, errUnusedAzureClusterNotFound
}
1093932
func (s *Sentinel) GetClusterWithPassword(name string, password string) (c *Cluster, err error) {
	return s.getCluster(name, password)
}
219550
func GetClusterBootstrapper(api libmachine.API, bootstrapperName string) (bootstrapper.Bootstrapper, error) {
	var b bootstrapper.Bootstrapper
	var err error
	switch bootstrapperName {
	case bootstrapper.BootstrapperTypeKubeadm:
		b, err = kubeadm.NewKubeadmBootstrapper(api)
		if err != nil {
			return nil, errors.Wrap(err, "getting kubeadm bootstrapper")
		}
	default:
		return nil, fmt.Errorf("Unknown bootstrapper: %s", bootstrapperName)
	}

	return b, nil
}
930546
func (a *AuthWithRoles) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) {
	if err := a.action(defaults.Namespace, services.KindClusterConfig, services.VerbRead); err != nil {
		return nil, trace.Wrap(err)
	}
	return a.authServer.GetClusterConfig(opts...)
}
856791
func LookupLease(coll mongo.Collection, namespace, name string) (leaseDoc, error) {
	var doc leaseDoc
	err := coll.FindId(leaseDocId(namespace, name)).One(&doc)
	if err != nil {
		return leaseDoc{}, err
	}
	return doc, nil
}
1344804
func (c *VFSClientset) GetCluster(name string) (*kops.Cluster, error) {
	return c.clusters().Get(name, metav1.GetOptions{})
}
296094
func (t *MemoryPool) GetLeaseForClient(macAddress net.HardwareAddr, clientID []byte) (bool, leasepool.Lease, error) {
	t.poolLock.Lock()
	defer t.poolLock.Unlock()

	needleKey := makeKey(macAddress, clientID)
	for i := range t.pool {
		haystackKey := makeKey(t.pool[i].MACAddress, t.pool[i].ClientID)
		if bytes.Equal(needleKey, haystackKey) {
			return true, t.pool[i], nil
		}
	}
	return false, leasepool.Lease{}, nil
}