Skip to content

Commit 5a2fe20

Browse files
Clean if statements
1 parent c7610e7 commit 5a2fe20

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

pkg/controller/siddhiprocess/siddhicontroller/siddhicontroller.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ func (sc *SiddhiController) CreateArtifacts(applications []deploymanager.Applica
182182

183183
sc.UpdatePartialAppStatus(applications)
184184
for _, application := range applications {
185-
if (eventType == controllerutil.OperationResultCreated) ||
186-
(eventType == controllerutil.OperationResultUpdated) {
185+
if eventType == controllerutil.OperationResultCreated ||
186+
eventType == controllerutil.OperationResultUpdated {
187187
deployManeger := deploymanager.DeployManager{
188188
Application: application,
189189
KubeClient: sc.KubeClient,
@@ -196,14 +196,14 @@ func (sc *SiddhiController) CreateArtifacts(applications []deploymanager.Applica
196196
sc.UpdateErrorStatus("AppDeploymentError", err)
197197
continue
198198
}
199-
if (eventType == controllerutil.OperationResultCreated) &&
200-
(operationResult == controllerutil.OperationResultCreated) {
199+
if eventType == controllerutil.OperationResultCreated &&
200+
operationResult == controllerutil.OperationResultCreated {
201201
sc.UpdateRunningStatus(
202202
"DeploymentCreated",
203203
(application.Name + " deployment created successfully"),
204204
)
205-
} else if (eventType == controllerutil.OperationResultUpdated) &&
206-
(operationResult == controllerutil.OperationResultUpdated) {
205+
} else if eventType == controllerutil.OperationResultUpdated &&
206+
operationResult == controllerutil.OperationResultUpdated {
207207
sc.UpdateRunningStatus(
208208
"DeploymentUpdated",
209209
(application.Name + " deployment updated successfully"),
@@ -222,14 +222,14 @@ func (sc *SiddhiController) CreateArtifacts(applications []deploymanager.Applica
222222
sc.UpdateErrorStatus("ServiceCreationError", err)
223223
continue
224224
}
225-
if (eventType == controllerutil.OperationResultCreated) &&
226-
(operationResult == controllerutil.OperationResultCreated) {
225+
if eventType == controllerutil.OperationResultCreated &&
226+
operationResult == controllerutil.OperationResultCreated {
227227
sc.UpdateRunningStatus(
228228
"ServiceCreated",
229229
(application.Name + " service created successfully"),
230230
)
231-
} else if (eventType == controllerutil.OperationResultUpdated) &&
232-
(operationResult == controllerutil.OperationResultUpdated) {
231+
} else if eventType == controllerutil.OperationResultUpdated &&
232+
operationResult == controllerutil.OperationResultUpdated {
233233
sc.UpdateRunningStatus(
234234
"ServiceUpdated",
235235
(application.Name + " service updated successfully"),
@@ -247,20 +247,19 @@ func (sc *SiddhiController) CreateArtifacts(applications []deploymanager.Applica
247247
sc.UpdateErrorStatus("IngressCreationError", err)
248248
continue
249249
}
250-
if (eventType == controllerutil.OperationResultCreated) &&
251-
(operationResult == controllerutil.OperationResultCreated) {
250+
if eventType == controllerutil.OperationResultCreated &&
251+
operationResult == controllerutil.OperationResultCreated {
252252
sc.Logger.Info("Ingress created", "Ingress.Name", artifact.IngressName)
253-
} else if (eventType == controllerutil.OperationResultUpdated) &&
254-
(operationResult == controllerutil.OperationResultUpdated) {
253+
} else if eventType == controllerutil.OperationResultUpdated &&
254+
operationResult == controllerutil.OperationResultUpdated {
255255
sc.Logger.Info("Ingress changed", "Ingress.Name", artifact.IngressName)
256256
}
257257
}
258258
}
259259
}
260260
}
261261
sc.SyncVersion()
262-
if (eventType == controllerutil.OperationResultCreated) ||
263-
(eventType == controllerutil.OperationResultUpdated) {
262+
if eventType == controllerutil.OperationResultCreated || eventType == controllerutil.OperationResultUpdated {
264263
sc.UpdateReadyDeployments(0, needDep)
265264
}
266265
return
@@ -433,32 +432,32 @@ func (sc *SiddhiController) UpdateDefaultConfigs() {
433432
configMap,
434433
)
435434
if err == nil {
436-
if configMap.Data["siddhiHome"] != "" {
437-
sc.Image.Home = configMap.Data["siddhiHome"]
435+
if v, ok := configMap.Data["siddhiHome"]; ok {
436+
sc.Image.Home = v
438437
}
439438

440-
if configMap.Data["siddhiImage"] != "" {
441-
sc.Image.Name = configMap.Data["siddhiImage"]
439+
if v, ok := configMap.Data["siddhiImage"]; ok {
440+
sc.Image.Name = v
442441
}
443442

444-
if configMap.Data["siddhiImageSecret"] != "" {
445-
sc.Image.Secret = configMap.Data["siddhiImageSecret"]
443+
if v, ok := configMap.Data["siddhiImageSecret"]; ok {
444+
sc.Image.Secret = v
446445
}
447446

448-
if configMap.Data["siddhiProfile"] != "" {
449-
sc.Image.Profile = configMap.Data["siddhiProfile"]
447+
if v, ok := configMap.Data["siddhiProfile"]; ok {
448+
sc.Image.Profile = v
450449
}
451450

452-
if configMap.Data["autoIngressCreation"] != "" {
453-
if configMap.Data["autoIngressCreation"] == "true" {
451+
if v, ok := configMap.Data["autoIngressCreation"]; ok {
452+
if v == "true" {
454453
sc.AutoCreateIngress = true
455454
} else {
456455
sc.AutoCreateIngress = false
457456
}
458457
}
459458

460-
if configMap.Data["ingressTLS"] != "" {
461-
sc.TLS = configMap.Data["ingressTLS"]
459+
if v, ok := configMap.Data["ingressTLS"]; ok {
460+
sc.TLS = v
462461
}
463462

464463
}
@@ -489,7 +488,7 @@ func (sc *SiddhiController) SetDefaultPendingState() {
489488
sc.SiddhiProcess.Status.CurrentVersion,
490489
sc.SiddhiProcess.Status.PreviousVersion,
491490
)
492-
if (eventType == controllerutil.OperationResultCreated) && (sc.SiddhiProcess.Status.Status == "") {
491+
if eventType == controllerutil.OperationResultCreated && sc.SiddhiProcess.Status.Status == "" {
493492
sc.UpdatePendingStatus()
494493
}
495494
}

0 commit comments

Comments
 (0)