mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-07-30 09:20:07 +00:00
Replace *core.Factory with CoreFactory interface
Make this field an interface instead of pointer to allow mocking. Not sure why wrangler has a type that returns an interface instead of just making it an interface itself. Wrangler in general is hard to mock for testing.
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit e6327652f0)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
committed by
Brad Davidson
parent
7f8f469a29
commit
ba74aa8a1a
@@ -141,9 +141,13 @@ func (c *Cluster) initClusterAndHTTPS(ctx context.Context) error {
|
||||
func tlsStorage(ctx context.Context, dataDir string, runtime *config.ControlRuntime) dynamiclistener.TLSStorage {
|
||||
fileStorage := file.New(filepath.Join(dataDir, "tls/dynamic-cert.json"))
|
||||
cache := memory.NewBacked(fileStorage)
|
||||
return kubernetes.New(ctx, func() *core.Factory {
|
||||
return runtime.Core
|
||||
}, metav1.NamespaceSystem, version.Program+"-serving", cache)
|
||||
coreGetter := func() *core.Factory {
|
||||
if coreFactory, ok := runtime.Core.(*core.Factory); ok {
|
||||
return coreFactory
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return kubernetes.New(ctx, coreGetter, metav1.NamespaceSystem, version.Program+"-serving", cache)
|
||||
}
|
||||
|
||||
// wrapHandler wraps the dynamiclistener request handler, adding a User-Agent value to
|
||||
|
||||
Reference in New Issue
Block a user