Move users of factory.NewConfigFactory to scheduler.New

This commit is contained in:
Guoliang Wang
2018-12-08 11:26:41 +08:00
parent 13e59ab9ad
commit 3c24c99b08
10 changed files with 131 additions and 258 deletions

View File

@@ -234,25 +234,6 @@ func initPolicyFromConfigMap(client clientset.Interface, policyRef *kubeschedule
return nil
}
// NewFromConfigurator returns a new scheduler that is created entirely by the Configurator. Assumes Create() is implemented.
// Supports intermediate Config mutation for now if you provide modifier functions which will run after Config is created.
func NewFromConfigurator(c factory.Configurator, modifiers ...func(c *factory.Config)) (*Scheduler, error) {
cfg, err := c.Create()
if err != nil {
return nil, err
}
// Mutate it if any functions were provided, changes might be required for certain types of tests (i.e. change the recorder).
for _, modifier := range modifiers {
modifier(cfg)
}
// From this point on the config is immutable to the outside.
s := &Scheduler{
config: cfg,
}
metrics.Register()
return s, nil
}
// NewFromConfig returns a new scheduler using the provided Config.
func NewFromConfig(config *factory.Config) *Scheduler {
metrics.Register()