Skip to content

Commit

Permalink
Support to disable telemetry
Browse files Browse the repository at this point in the history
Closes #231
  • Loading branch information
eromanova committed Aug 27, 2024
1 parent 54a9ce3 commit d832dc6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func main() {
var createManagement bool
var createTemplates bool
var hmcTemplatesChartName string
var enableTelemetry bool
var enableWebhook bool
var webhookPort int
var webhookCertDir string
Expand All @@ -85,6 +86,7 @@ func main() {
flag.BoolVar(&createTemplates, "create-templates", true, "Create HMC Templates.")
flag.StringVar(&hmcTemplatesChartName, "hmc-templates-chart-name", "hmc-templates",
"The name of the helm chart with HMC Templates.")
flag.BoolVar(&enableTelemetry, "enable-telemetry", true, "Collect and send telemetry data.")
flag.BoolVar(&enableWebhook, "enable-webhook", true, "Enable admission webhook.")
flag.IntVar(&webhookPort, "webhook-port", 9443, "Admission webhook port.")
flag.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
Expand Down Expand Up @@ -187,11 +189,13 @@ func main() {
os.Exit(1)
}

if err = mgr.Add(&telemetry.Tracker{
Client: mgr.GetClient(),
}); err != nil {
setupLog.Error(err, "unable to create telemetry tracker")
os.Exit(1)
if enableTelemetry {
if err = mgr.Add(&telemetry.Tracker{
Client: mgr.GetClient(),
}); err != nil {
setupLog.Error(err, "unable to create telemetry tracker")
os.Exit(1)
}
}

//+kubebuilder:scaffold:builder
Expand Down
1 change: 1 addition & 0 deletions templates/hmc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
{{- end }}
- --create-management={{ .Values.controller.createManagement }}
- --create-templates={{ .Values.controller.createTemplates }}
- --enable-telemetry={{ .Values.controller.enableTelemetry }}
- --enable-webhook={{ .Values.admissionWebhook.enabled }}
- --webhook-port={{ .Values.admissionWebhook.port }}
- --webhook-cert-dir={{ .Values.admissionWebhook.certDir }}
Expand Down
3 changes: 3 additions & 0 deletions templates/hmc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
},
"createTemplate": {
"type": "boolean"
},
"enableTelemetry": {
"type": "boolean"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions templates/hmc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ controller:
insecureRegistry: false
createManagement: true
createTemplates: true
enableTelemetry: true

containerSecurityContext:
allowPrivilegeEscalation: false
Expand Down

0 comments on commit d832dc6

Please sign in to comment.