fakestore.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package store
  14. import (
  15. "fmt"
  16. "time"
  17. kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
  18. "k8s.io/kubernetes/pkg/kubelet/kubeletconfig/checkpoint"
  19. )
  20. // so far only implements Assigned(), LastKnownGood(), SetAssigned(), and SetLastKnownGood()
  21. type fakeStore struct {
  22. assigned checkpoint.RemoteConfigSource
  23. lastKnownGood checkpoint.RemoteConfigSource
  24. }
  25. var _ Store = (*fakeStore)(nil)
  26. // NewFakeStore constructs a fake Store
  27. func NewFakeStore() Store {
  28. return &fakeStore{}
  29. }
  30. func (s *fakeStore) Initialize() error {
  31. return fmt.Errorf("Initialize method not supported")
  32. }
  33. func (s *fakeStore) Exists(source checkpoint.RemoteConfigSource) (bool, error) {
  34. return false, fmt.Errorf("Exists method not supported")
  35. }
  36. func (s *fakeStore) Save(c checkpoint.Payload) error {
  37. return fmt.Errorf("Save method not supported")
  38. }
  39. func (s *fakeStore) Load(source checkpoint.RemoteConfigSource) (*kubeletconfig.KubeletConfiguration, error) {
  40. return nil, fmt.Errorf("Load method not supported")
  41. }
  42. func (s *fakeStore) AssignedModified() (time.Time, error) {
  43. return time.Time{}, fmt.Errorf("AssignedModified method not supported")
  44. }
  45. func (s *fakeStore) Assigned() (checkpoint.RemoteConfigSource, error) {
  46. return s.assigned, nil
  47. }
  48. func (s *fakeStore) LastKnownGood() (checkpoint.RemoteConfigSource, error) {
  49. return s.lastKnownGood, nil
  50. }
  51. func (s *fakeStore) SetAssigned(source checkpoint.RemoteConfigSource) error {
  52. s.assigned = source
  53. return nil
  54. }
  55. func (s *fakeStore) SetLastKnownGood(source checkpoint.RemoteConfigSource) error {
  56. s.lastKnownGood = source
  57. return nil
  58. }
  59. func (s *fakeStore) Reset() (bool, error) {
  60. return false, fmt.Errorf("Reset method not supported")
  61. }