func allocate() (allocationv1.GameServerAllocationState, error) {
	// Log the values used in the allocation
	logger.WithField("namespace", namespace).Info("namespace for gsa")
	logger.WithField("fleetname", fleetname).Info("fleetname for gsa")

	// Find out how many ready replicas the fleet has - we need at least one
	readyReplicas := checkReadyReplicas()
	logger.WithField("readyReplicas", readyReplicas).Info("number of ready replicas")

	// Log and return an error if there are no ready replicas
	if readyReplicas < 1 {
		logger.WithField("fleetname", fleetname).Info("Insufficient ready replicas, cannot create fleet allocation")
		return allocationv1.GameServerAllocationUnAllocated, errors.New("insufficient ready replicas, cannot create fleet allocation")
	}

	// Get a AllocationInterface for this namespace
	allocationInterface := agonesClient.AllocationV1().GameServerAllocations(namespace)

	// Define the allocation using the constants set earlier
	gsa := &allocationv1.GameServerAllocation{
		Spec: allocationv1.GameServerAllocationSpec{
			Required: metav1.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: fleetname}},
		}}

	// Create a new allocation
	gsa, err := allocationInterface.Create(gsa)
	if err != nil {
		// Log and return the error if the call to Create fails
		logger.WithError(err).Info("Failed to create allocation")
		return allocationv1.GameServerAllocationUnAllocated, errors.New("failed to create allocation")
	}

	// Log the GameServer.Staus of the new allocation, then return those values
	logger.Info("New GameServer allocated: ", gsa.Status.State)
	return gsa.Status.State, nil
}
// Move a replica from ready to allocated and return the GameServerStatus
Move a replica from ready to allocated and return the GameServerStatus
// Move a replica from ready to allocated and return the GameServerStatus
func allocate() (allocationv1.GameServerAllocationState, error) {
	logger.WithField("namespace", namespace).Info("namespace for gsa")
	logger.WithField("fleetname", fleetname).Info("fleetname for gsa")
	readyReplicas := checkReadyReplicas()
	logger.WithField("readyReplicas", readyReplicas).Info("number of ready replicas")
	if readyReplicas < 1 {
		logger.WithField("fleetname", fleetname).Info("Insufficient ready replicas, cannot create fleet allocation")
		return allocationv1.GameServerAllocationUnAllocated, errors.New("insufficient ready replicas, cannot create fleet allocation")
	}
	allocationInterface := agonesClient.AllocationV1().GameServerAllocations(namespace)
	gsa := &allocationv1.GameServerAllocation{
		Spec: allocationv1.GameServerAllocationSpec{
			Required: metav1.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: fleetname}},
		}}
	gsa, err := allocationInterface.Create(gsa)
	if err != nil {
		logger.WithError(err).Info("Failed to create allocation")
		return allocationv1.GameServerAllocationUnAllocated, errors.New("failed to create allocation")
	}
	logger.Info("New GameServer allocated: ", gsa.Status.State)
	return gsa.Status.State, nil
}
func allocate ( ) ( allocationv1 . GameServerAllocationState , error ) { logger . WithField ( " " , namespace ) . Info ( " " ) logger . WithField ( " " , fleetname ) . Info ( " " ) readyReplicas := checkReadyReplicas ( ) logger . WithField ( " " , readyReplicas ) . Info ( " " ) if readyReplicas < 1 { logger . WithField ( " " , fleetname ) . Info ( " " ) return allocationv1 . GameServerAllocationUnAllocated , errors . New ( " " ) } allocationInterface := agonesClient . AllocationV1 ( ) . GameServerAllocations ( namespace ) gsa := & allocationv1 . GameServerAllocation { Spec : allocationv1 . GameServerAllocationSpec { Required : metav1 . LabelSelector { MatchLabels : map [ string ] string { agonesv1 . FleetNameLabel : fleetname } } , } } gsa , err := allocationInterface . Create ( gsa ) if err != nil { logger . WithError ( err ) . Info ( " " ) return allocationv1 . GameServerAllocationUnAllocated , errors . New ( " " ) } logger . Info ( " " , gsa . Status . State ) return gsa . Status . State , nil }
Move a replica from ready to allocated and return the GameServerStatus
Move a replica from ready to allocated and return the GameServerStatus
// Log the values used in the allocation // Find out how many ready replicas the fleet has - we need at least one // Log and return an error if there are no ready replicas // Get a AllocationInterface for this namespace // Define the allocation using the constants set earlier // Create a new allocation // Log and return the error if the call to Create fails // Log the GameServer.Staus of the new allocation, then return those values