@@ -3,11 +3,10 @@ package main
3
3
import (
4
4
"flag"
5
5
"fmt"
6
- "github.com/cyclops-ui/cycops-ctrl/internal/auth"
7
- "github.com/cyclops-ui/cycops-ctrl/internal/template"
8
- "github.com/cyclops-ui/cycops-ctrl/internal/template/cache"
9
6
"os"
7
+ "strconv"
10
8
9
+ _ "github.com/joho/godotenv/autoload"
11
10
"k8s.io/apimachinery/pkg/runtime"
12
11
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
13
12
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -17,10 +16,14 @@ import (
17
16
"sigs.k8s.io/controller-runtime/pkg/log/zap"
18
17
19
18
cyclopsv1alpha1 "github.com/cyclops-ui/cycops-ctrl/api/v1alpha1"
19
+ "github.com/cyclops-ui/cycops-ctrl/internal/auth"
20
20
"github.com/cyclops-ui/cycops-ctrl/internal/cluster/k8sclient"
21
21
"github.com/cyclops-ui/cycops-ctrl/internal/handler"
22
22
"github.com/cyclops-ui/cycops-ctrl/internal/modulecontroller"
23
23
"github.com/cyclops-ui/cycops-ctrl/internal/storage/templates"
24
+ "github.com/cyclops-ui/cycops-ctrl/internal/telemetry"
25
+ "github.com/cyclops-ui/cycops-ctrl/internal/template"
26
+ "github.com/cyclops-ui/cycops-ctrl/internal/template/cache"
24
27
)
25
28
26
29
var (
@@ -54,6 +57,9 @@ func main() {
54
57
55
58
setupLog .Info ("starting handler" )
56
59
60
+ telemetryClient , _ := telemetry .NewClient (getEnvBool ("DISABLE_TELEMETRY" ))
61
+ telemetryClient .InstanceStart ()
62
+
57
63
k8sClient , err := k8sclient .New ()
58
64
if err != nil {
59
65
fmt .Println ("error bootstrapping Kubernetes client" , err )
@@ -71,7 +77,7 @@ func main() {
71
77
cache .NewInMemoryTemplatesCache (),
72
78
)
73
79
74
- handler , err := handler .New (templatesStorage , templatesRepo , k8sClient )
80
+ handler , err := handler .New (templatesStorage , templatesRepo , k8sClient , telemetryClient )
75
81
if err != nil {
76
82
panic (err )
77
83
}
@@ -97,6 +103,7 @@ func main() {
97
103
templatesRepo ,
98
104
templatesStorage ,
99
105
k8sClient ,
106
+ telemetryClient ,
100
107
)).SetupWithManager (mgr ); err != nil {
101
108
setupLog .Error (err , "unable to create controller" , "controller" , "Module" )
102
109
os .Exit (1 )
@@ -118,3 +125,15 @@ func main() {
118
125
os .Exit (1 )
119
126
}
120
127
}
128
+
129
+ func getEnvBool (key string ) bool {
130
+ value := os .Getenv (key )
131
+ if value == "" {
132
+ return false
133
+ }
134
+ b , err := strconv .ParseBool (value )
135
+ if err != nil {
136
+ return false
137
+ }
138
+ return b
139
+ }
0 commit comments