forked from googleforgames/agones
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GameServerSets are the basic building block for Fleets. GameServerSets will be allow Fleet migrations to occur, similarly to how ReplicaSets allow Deployments to migrate one image type to another. This has not been formally documented, as this will likely be an internal CRD, and not (widely) used externally. Parent ticket: googleforgames#70
- Loading branch information
1 parent
c996f76
commit ca9779a
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2018 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package gameserversets | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
agonesfake "agones.dev/agones/pkg/client/clientset/versioned/fake" | ||
"agones.dev/agones/pkg/client/informers/externalversions" | ||
"github.com/sirupsen/logrus" | ||
extfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" | ||
kubefake "k8s.io/client-go/kubernetes/fake" | ||
"k8s.io/client-go/tools/cache" | ||
"k8s.io/client-go/tools/record" | ||
) | ||
|
||
// holder for all my fakes and mocks | ||
type mocks struct { | ||
kubeClient *kubefake.Clientset | ||
extClient *extfake.Clientset | ||
agonesClient *agonesfake.Clientset | ||
agonesInformerFactory externalversions.SharedInformerFactory | ||
fakeRecorder *record.FakeRecorder | ||
} | ||
|
||
func newMocks() mocks { | ||
kubeClient := &kubefake.Clientset{} | ||
extClient := &extfake.Clientset{} | ||
agonesClient := &agonesfake.Clientset{} | ||
agonesInformerFactory := externalversions.NewSharedInformerFactory(agonesClient, 30*time.Second) | ||
m := mocks{ | ||
kubeClient: kubeClient, | ||
extClient: extClient, | ||
agonesClient: agonesClient, | ||
agonesInformerFactory: agonesInformerFactory, | ||
fakeRecorder: record.NewFakeRecorder(10), | ||
} | ||
return m | ||
} | ||
|
||
func startInformers(mocks mocks, sync ...cache.InformerSynced) (<-chan struct{}, context.CancelFunc) { | ||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
stop := ctx.Done() | ||
|
||
mocks.agonesInformerFactory.Start(stop) | ||
|
||
logrus.Info("Wait for cache sync") | ||
if !cache.WaitForCacheSync(stop, sync...) { | ||
panic("Cache never synced") | ||
} | ||
|
||
return stop, cancel | ||
} |