forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.go
54 lines (45 loc) · 1.57 KB
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package controller
import (
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
templatecontroller "github.com/openshift/origin/pkg/template/controller"
"k8s.io/client-go/dynamic"
)
func RunTemplateInstanceController(ctx *ControllerContext) (bool, error) {
saName := bootstrappolicy.InfraTemplateInstanceControllerServiceAccountName
restConfig, err := ctx.ClientBuilder.Config(saName)
if err != nil {
return true, err
}
dynamicClient, err := dynamic.NewForConfig(restConfig)
if err != nil {
return true, err
}
go templatecontroller.NewTemplateInstanceController(
ctx.RestMapper,
dynamicClient,
ctx.ClientBuilder.ClientGoClientOrDie(saName).AuthorizationV1(),
ctx.ClientBuilder.ClientGoClientOrDie(saName),
ctx.ClientBuilder.OpenshiftBuildClientOrDie(saName),
ctx.ClientBuilder.OpenshiftTemplateClientOrDie(saName).TemplateV1(),
ctx.InternalTemplateInformers.Template().V1().TemplateInstances(),
).Run(5, ctx.Stop)
return true, nil
}
func RunTemplateInstanceFinalizerController(ctx *ControllerContext) (bool, error) {
saName := bootstrappolicy.InfraTemplateInstanceFinalizerControllerServiceAccountName
restConfig, err := ctx.ClientBuilder.Config(saName)
if err != nil {
return true, err
}
dynamicClient, err := dynamic.NewForConfig(restConfig)
if err != nil {
return true, err
}
go templatecontroller.NewTemplateInstanceFinalizerController(
ctx.RestMapper,
dynamicClient,
ctx.ClientBuilder.OpenshiftTemplateClientOrDie(saName),
ctx.InternalTemplateInformers.Template().V1().TemplateInstances(),
).Run(5, ctx.Stop)
return true, nil
}