@@ -76,52 +76,12 @@ func (c *Config) loadHTTP(data map[string][]byte) {
76
76
}
77
77
78
78
func (c * Config ) loadReport (data map [string ][]byte ) {
79
- if enableGlobalObfuscation , ok := data ["enableGlobalObfuscation" ]; ok {
80
- c .EnableGlobalObfuscation = strings .EqualFold (string (enableGlobalObfuscation ), "true" )
81
- }
82
-
83
- if reportEndpoint , ok := data ["reportEndpoint" ]; ok {
84
- c .ReportEndpoint = string (reportEndpoint )
85
- }
86
- if reportPullingDelay , ok := data ["reportPullingDelay" ]; ok {
87
- if v , err := time .ParseDuration (string (reportPullingDelay )); err == nil {
88
- c .ReportPullingDelay = v
89
- } else {
90
- klog .Warningf (
91
- "reportPullingDelay secret contains an invalid value (%s). Using previous value" ,
92
- reportPullingDelay ,
93
- )
94
- }
95
- } else {
96
- c .ReportPullingDelay = time .Duration (- 1 )
97
- }
98
-
99
- if reportPullingTimeout , ok := data ["reportPullingTimeout" ]; ok {
100
- if v , err := time .ParseDuration (string (reportPullingTimeout )); err == nil {
101
- c .ReportPullingTimeout = v
102
- } else {
103
- klog .Warningf (
104
- "reportPullingTimeout secret contains an invalid value (%s). Using previous value" ,
105
- reportPullingTimeout ,
106
- )
107
- }
108
- }
109
-
110
- if reportMinRetryTime , ok := data ["reportMinRetryTime" ]; ok {
111
- if v , err := time .ParseDuration (string (reportMinRetryTime )); err == nil {
112
- c .ReportMinRetryTime = v
113
- } else {
114
- klog .Warningf (
115
- "reportMinRetryTime secret contains an invalid value (%s). Using previous value" ,
116
- reportMinRetryTime ,
117
- )
118
- }
119
- }
120
-
121
- c .Report = len (c .Endpoint ) > 0
122
- if disableInsightsAlerts , ok := data ["disableInsightsAlerts" ]; ok {
123
- c .DisableInsightsAlerts = strings .EqualFold (string (disableInsightsAlerts ), "true" )
124
- }
79
+ c .loadEnableGlobalObfuscation (data )
80
+ c .loadReportEndpoint (data )
81
+ c .loadReportPullingDelay (data )
82
+ c .loadReportPullingTimeout (data )
83
+ c .loadReportMinRetryTime (data )
84
+ c .loadReportSettings (data )
125
85
}
126
86
127
87
func (c * Config ) loadOCM (data map [string ][]byte ) {
@@ -168,3 +128,48 @@ func (c *Config) loadReportEndpointTechPreview(data map[string][]byte) {
168
128
c .ReportEndpointTechPreview = string (endpoint )
169
129
}
170
130
}
131
+
132
+ func (c * Config ) loadEnableGlobalObfuscation (data map [string ][]byte ) {
133
+ if enableGlobalObfuscation , ok := data ["enableGlobalObfuscation" ]; ok {
134
+ c .EnableGlobalObfuscation = strings .EqualFold (string (enableGlobalObfuscation ), "true" )
135
+ }
136
+ }
137
+
138
+ func (c * Config ) loadReportEndpoint (data map [string ][]byte ) {
139
+ if reportEndpoint , ok := data ["reportEndpoint" ]; ok {
140
+ c .ReportEndpoint = string (reportEndpoint )
141
+ }
142
+ }
143
+
144
+ func (c * Config ) loadReportPullingDelay (data map [string ][]byte ) {
145
+ c .loadReportDurationSetting (data , "reportPullingDelay" , & c .ReportPullingDelay )
146
+ }
147
+
148
+ func (c * Config ) loadReportPullingTimeout (data map [string ][]byte ) {
149
+ c .loadReportDurationSetting (data , "reportPullingTimeout" , & c .ReportPullingTimeout )
150
+ }
151
+
152
+ func (c * Config ) loadReportMinRetryTime (data map [string ][]byte ) {
153
+ c .loadReportDurationSetting (data , "reportMinRetryTime" , & c .ReportMinRetryTime )
154
+ }
155
+
156
+ func (c * Config ) loadReportDurationSetting (data map [string ][]byte , key string , target * time.Duration ) {
157
+ if value , ok := data [key ]; ok {
158
+ if v , err := time .ParseDuration (string (value )); err == nil {
159
+ * target = v
160
+ } else {
161
+ klog .Warningf ("%s secret contains an invalid value (%s). Using previous value" , key , value )
162
+ }
163
+ } else {
164
+ if key == "reportPullingDelay" {
165
+ * target = time .Duration (- 1 )
166
+ }
167
+ }
168
+ }
169
+
170
+ func (c * Config ) loadReportSettings (data map [string ][]byte ) {
171
+ c .Report = len (c .Endpoint ) > 0
172
+ if disableInsightsAlerts , ok := data ["disableInsightsAlerts" ]; ok {
173
+ c .DisableInsightsAlerts = strings .EqualFold (string (disableInsightsAlerts ), "true" )
174
+ }
175
+ }
0 commit comments