|
| 1 | +/* |
| 2 | +Copyright 2025 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 dependency |
| 18 | + |
| 19 | +import ( |
| 20 | + "k8s.io/perf-tests/clusterloader2/pkg/config" |
| 21 | + "k8s.io/perf-tests/clusterloader2/pkg/framework" |
| 22 | + "k8s.io/perf-tests/clusterloader2/pkg/provider" |
| 23 | + |
| 24 | + "k8s.io/apimachinery/pkg/version" |
| 25 | +) |
| 26 | + |
| 27 | +// Config provides client and parameters required for the dependency execution. |
| 28 | +type Config struct { |
| 29 | + // ClusterFramework returns cluster framework. |
| 30 | + ClusterFramework *framework.Framework |
| 31 | + // PrometheusFramework returns prometheus framework. |
| 32 | + PrometheusFramework *framework.Framework |
| 33 | + // Params is a map of {name: value} pairs enabling for injection of arbitrary config |
| 34 | + // into the Execute method. |
| 35 | + Params map[string]interface{} |
| 36 | + // TemplateProvider provides templated objects. |
| 37 | + TemplateProvider *config.TemplateProvider |
| 38 | + ClusterLoaderConfig *config.ClusterLoaderConfig |
| 39 | + |
| 40 | + // Method identifies this instance of dependency. |
| 41 | + Method string |
| 42 | + CloudProvider provider.Provider |
| 43 | + |
| 44 | + // ClusterVersion contains the version of the cluster and is used to select |
| 45 | + // available features. |
| 46 | + ClusterVersion version.Info |
| 47 | +} |
| 48 | + |
| 49 | +// Dependency is a common interface for all dependency methods. It should be implemented by the user to |
| 50 | +// allow dependency method to be registered in the dependency factory. |
| 51 | +type Dependency interface { |
| 52 | + // Setup sets up the dependency and returns an error if setup fails. |
| 53 | + Setup(config *Config) error |
| 54 | + // Teardown tears down the dependency and returns an error if teardown fails. |
| 55 | + Teardown(config *Config) error |
| 56 | + // String returns a string representation of the dependency. |
| 57 | + String() string |
| 58 | +} |
| 59 | + |
| 60 | +type createDependencyFunc func() Dependency |
0 commit comments