@@ -22,10 +22,12 @@ import (
22
22
)
23
23
24
24
const (
25
- crdTmplName = "deploy/crd.yaml"
26
- operatorTmplName = "deploy/operator.yaml"
27
- rbacTmplName = "deploy/rbac.yaml"
28
- crTmplName = "deploy/cr.yaml"
25
+ crdTmplName = "deploy/crd.yaml"
26
+ operatorTmplName = "deploy/operator.yaml"
27
+ rbacTmplName = "deploy/rbac.yaml"
28
+ crTmplName = "deploy/cr.yaml"
29
+ serviceTmplName = "deploy/service.yaml"
30
+ serviceMonitorTmplName = "deploy/serviceMonitor.yaml"
29
31
)
30
32
31
33
// CRDYaml contains data needed to generate deploy/crd.yaml
@@ -77,6 +79,47 @@ func renderOperatorYaml(w io.Writer, projectName, image string) error {
77
79
return t .Execute (w , o )
78
80
}
79
81
82
+ // ServiceYaml contains all the customized data needed to generate deploy/service.yaml for a new operator
83
+ // This service will be monitor by prometheus
84
+ // when pairing with serviceYamlTmpl template.
85
+ type ServiceYaml struct {
86
+ ProjectName string
87
+ }
88
+
89
+ // renderServiceYaml generates deploy/service.yaml.
90
+ func renderServiceYaml (w io.Writer , projectName string ) error {
91
+ t := template .New (serviceTmplName )
92
+ t , err := t .Parse (serviceYamlTmpl )
93
+ if err != nil {
94
+ return fmt .Errorf ("Failed to parse service yaml template: %v" , err )
95
+ }
96
+
97
+ s := ServiceYaml {
98
+ ProjectName : projectName ,
99
+ }
100
+ return t .Execute (w , s )
101
+ }
102
+
103
+ // ServiceMonitorYaml contains all the customized data needed to generate deploy/serviceMonitor.yaml for a new operator
104
+ // when pairing with serviceMonitorYamlTmpl template.
105
+ type ServiceMonitorYaml struct {
106
+ ProjectName string
107
+ }
108
+
109
+ // renderServiceYaml generates deploy/service.yaml.
110
+ func renderServiceMonitorYaml (w io.Writer , projectName string ) error {
111
+ t := template .New (serviceMonitorTmplName )
112
+ t , err := t .Parse (serviceMonitorYamlTmpl )
113
+ if err != nil {
114
+ return fmt .Errorf ("Failed to parse serviceMonitor yaml template: %v" , err )
115
+ }
116
+
117
+ s := ServiceYaml {
118
+ ProjectName : projectName ,
119
+ }
120
+ return t .Execute (w , s )
121
+ }
122
+
80
123
// RBACYaml contains all the customized data needed to generate deploy/rbac.yaml for a new operator
81
124
// when pairing with rbacYamlTmpl template.
82
125
type RBACYaml struct {
0 commit comments