mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-31 16:46:54 +00:00
feat: make loadConfig
and loadConfigFile
public functions
- so that users who import kube-scheduler libraries can use these functions to read kube scheduler config
This commit is contained in:
@@ -30,16 +30,16 @@ import (
|
||||
configv1beta3 "k8s.io/kubernetes/pkg/scheduler/apis/config/v1beta3"
|
||||
)
|
||||
|
||||
func loadConfigFromFile(logger klog.Logger, file string) (*config.KubeSchedulerConfiguration, error) {
|
||||
func LoadConfigFromFile(logger klog.Logger, file string) (*config.KubeSchedulerConfiguration, error) {
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return loadConfig(logger, data)
|
||||
return LoadConfig(logger, data)
|
||||
}
|
||||
|
||||
func loadConfig(logger klog.Logger, data []byte) (*config.KubeSchedulerConfiguration, error) {
|
||||
func LoadConfig(logger klog.Logger, data []byte) (*config.KubeSchedulerConfiguration, error) {
|
||||
// The UniversalDecoder runs defaulting and returns the internal type by default.
|
||||
obj, gvk, err := scheme.Codecs.UniversalDecoder().Decode(data, nil, nil)
|
||||
if err != nil {
|
||||
|
@@ -204,7 +204,7 @@ func (o *Options) ApplyTo(logger klog.Logger, c *schedulerappconfig.Config) erro
|
||||
o.ApplyLeaderElectionTo(o.ComponentConfig)
|
||||
c.ComponentConfig = *o.ComponentConfig
|
||||
} else {
|
||||
cfg, err := loadConfigFromFile(logger, o.ConfigFile)
|
||||
cfg, err := LoadConfigFromFile(logger, o.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user