Skip to content

Commit 2a68b3b

Browse files
author
eliranb
committed
Refactor determineWorkloadType function to streamline workload type determination for LightrunJavaAgent. Simplify logic by removing unnecessary checks and enhancing clarity in configuration handling.
1 parent 22505e3 commit 2a68b3b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

internal/controller/lightrunjavaagent_controller.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,11 @@ func (r *LightrunJavaAgentReconciler) determineWorkloadType(lightrunJavaAgent *a
102102
if !isDeploymentConfigured && !isWorkloadConfigured {
103103
return "", errors.New("invalid configuration: must set either DeploymentName (legacy) or WorkloadName with WorkloadType")
104104
}
105-
106-
switch {
107-
case isDeploymentConfigured:
105+
if isDeploymentConfigured {
108106
r.Log.Info("Using deprecated field deploymentName, consider migrating to workloadName and workloadType")
109107
return agentv1beta.WorkloadTypeDeployment, nil
110-
case isWorkloadConfigured:
111-
return spec.WorkloadType, nil
112-
default:
113-
return "", errors.New("unable to determine workload type, please check your configuration")
114108
}
109+
return spec.WorkloadType, nil
115110
}
116111

117112
// reconcileDeployment handles the reconciliation logic for Deployment workloads

0 commit comments

Comments
 (0)