k8s.io/kubernetes@v1.29.3/pkg/scheduler/internal/cache/fake/fake_cache.go (about)

     1  /*
     2  Copyright 2015 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package fake
    18  
    19  import (
    20  	v1 "k8s.io/api/core/v1"
    21  	"k8s.io/klog/v2"
    22  	"k8s.io/kubernetes/pkg/scheduler/framework"
    23  	internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
    24  )
    25  
    26  // Cache is used for testing
    27  type Cache struct {
    28  	AssumeFunc       func(*v1.Pod)
    29  	ForgetFunc       func(*v1.Pod)
    30  	IsAssumedPodFunc func(*v1.Pod) bool
    31  	GetPodFunc       func(*v1.Pod) *v1.Pod
    32  }
    33  
    34  // AssumePod is a fake method for testing.
    35  func (c *Cache) AssumePod(logger klog.Logger, pod *v1.Pod) error {
    36  	c.AssumeFunc(pod)
    37  	return nil
    38  }
    39  
    40  // FinishBinding is a fake method for testing.
    41  func (c *Cache) FinishBinding(logger klog.Logger, pod *v1.Pod) error { return nil }
    42  
    43  // ForgetPod is a fake method for testing.
    44  func (c *Cache) ForgetPod(logger klog.Logger, pod *v1.Pod) error {
    45  	c.ForgetFunc(pod)
    46  	return nil
    47  }
    48  
    49  // AddPod is a fake method for testing.
    50  func (c *Cache) AddPod(logger klog.Logger, pod *v1.Pod) error { return nil }
    51  
    52  // UpdatePod is a fake method for testing.
    53  func (c *Cache) UpdatePod(logger klog.Logger, oldPod, newPod *v1.Pod) error { return nil }
    54  
    55  // RemovePod is a fake method for testing.
    56  func (c *Cache) RemovePod(logger klog.Logger, pod *v1.Pod) error { return nil }
    57  
    58  // IsAssumedPod is a fake method for testing.
    59  func (c *Cache) IsAssumedPod(pod *v1.Pod) (bool, error) {
    60  	return c.IsAssumedPodFunc(pod), nil
    61  }
    62  
    63  // GetPod is a fake method for testing.
    64  func (c *Cache) GetPod(pod *v1.Pod) (*v1.Pod, error) {
    65  	return c.GetPodFunc(pod), nil
    66  }
    67  
    68  // AddNode is a fake method for testing.
    69  func (c *Cache) AddNode(logger klog.Logger, node *v1.Node) *framework.NodeInfo { return nil }
    70  
    71  // UpdateNode is a fake method for testing.
    72  func (c *Cache) UpdateNode(logger klog.Logger, oldNode, newNode *v1.Node) *framework.NodeInfo {
    73  	return nil
    74  }
    75  
    76  // RemoveNode is a fake method for testing.
    77  func (c *Cache) RemoveNode(logger klog.Logger, node *v1.Node) error { return nil }
    78  
    79  // UpdateSnapshot is a fake method for testing.
    80  func (c *Cache) UpdateSnapshot(logger klog.Logger, snapshot *internalcache.Snapshot) error {
    81  	return nil
    82  }
    83  
    84  // NodeCount is a fake method for testing.
    85  func (c *Cache) NodeCount() int { return 0 }
    86  
    87  // PodCount is a fake method for testing.
    88  func (c *Cache) PodCount() (int, error) { return 0, nil }
    89  
    90  // Dump is a fake method for testing.
    91  func (c *Cache) Dump() *internalcache.Dump {
    92  	return &internalcache.Dump{}
    93  }