crossplane
39 строк · 1.1 Кб
1/*
2Copyright 2023 The Crossplane Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package config
18
19// MockSource is a mock source.
20type MockSource struct {
21InitializeFn func() error
22GetConfigFn func() (*Config, error)
23UpdateConfigFn func(*Config) error
24}
25
26// Initialize calls the underlying initialize function.
27func (m *MockSource) Initialize() error {
28return m.InitializeFn()
29}
30
31// GetConfig calls the underlying get config function.
32func (m *MockSource) GetConfig() (*Config, error) {
33return m.GetConfigFn()
34}
35
36// UpdateConfig calls the underlying update config function.
37func (m *MockSource) UpdateConfig(c *Config) error {
38return m.UpdateConfigFn(c)
39}
40