agones.dev/agones@v1.53.0/pkg/cloudproduct/generic/generic.go (about) 1 // Copyright 2022 Google LLC All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package generic implements generic cloud product hooks 16 package generic 17 18 import ( 19 "agones.dev/agones/pkg/apis" 20 agonesv1 "agones.dev/agones/pkg/apis/agones/v1" 21 "agones.dev/agones/pkg/client/informers/externalversions" 22 "agones.dev/agones/pkg/cloudproduct/eviction" 23 "agones.dev/agones/pkg/portallocator" 24 corev1 "k8s.io/api/core/v1" 25 "k8s.io/apimachinery/pkg/util/validation/field" 26 "k8s.io/client-go/informers" 27 ) 28 29 // New returns a new generic cloud product 30 // 31 //nolint:revive // ignore the unexported return; implements ControllerHooksInterface 32 func New() *generic { return &generic{} } 33 34 type generic struct{} 35 36 func (*generic) ValidateGameServerSpec(*agonesv1.GameServerSpec, *field.Path) field.ErrorList { 37 return nil 38 } 39 func (*generic) ValidateScheduling(apis.SchedulingStrategy, *field.Path) field.ErrorList { return nil } 40 func (*generic) MutateGameServerPod(*agonesv1.GameServerSpec, *corev1.Pod) error { return nil } 41 42 // SetEviction sets disruptions controls based on GameServer.Status.Eviction. 43 func (*generic) SetEviction(ev *agonesv1.Eviction, pod *corev1.Pod) error { 44 return eviction.SetEviction(ev, pod) 45 } 46 47 func (*generic) SyncPodPortsToGameServer(*agonesv1.GameServer, *corev1.Pod) error { return nil } 48 49 func (*generic) NewPortAllocator(portRanges map[string]portallocator.PortRange, 50 kubeInformerFactory informers.SharedInformerFactory, 51 agonesInformerFactory externalversions.SharedInformerFactory) portallocator.Interface { 52 return portallocator.New(portRanges, kubeInformerFactory, agonesInformerFactory) 53 } 54 55 func (*generic) WaitOnFreePorts() bool { return false }