dashanji commented on code in PR #66:
URL: https://github.com/apache/skywalking-swck/pull/66#discussion_r906938600


##########
operator/pkg/operator/injector/webhook.go:
##########
@@ -63,11 +68,35 @@ func (r *JavaagentInjector) Handle(ctx context.Context, req 
admission.Request) a
        // initialize SidecarInjectField and get injected strategy from 
annotations
        s := NewSidecarInjectField()
        // initialize InjectProcess as a call chain
-       ip := NewInjectProcess(ctx, s, anno, ao, pod, req, 
javaagentInjectorLog, r.Client)
+       ip := NewInjectProcess(ctx, s, anno, ao, swAgentL, pod, req, 
javaagentInjectorLog, r.Client)
        // do real injection
        return ip.Run()
 }
 
+func (r *JavaagentInjector) findMatchedSwAgentL(ctx context.Context, req 
admission.Request, pod *corev1.Pod) *v1alpha1.SwAgentList {
+       swAgentList := &v1alpha1.SwAgentList{}
+       if err := r.Client.List(ctx, swAgentList, 
client.InNamespace(req.Namespace)); err != nil {
+               javaagentInjectorLog.Error(err, "get SwAgent error")
+       }
+
+       // selector
+       var availableSwAgentL []v1alpha1.SwAgent
+       for _, swAgent := range swAgentList.Items {
+               isMatch := true
+               if len(swAgent.Spec.Selector) != 0 {
+                       for k, v := range swAgent.Spec.Selector {
+                               if !strings.EqualFold(v, pod.Labels[k]) {
+                                       isMatch = false
+                               }
+                       }
+               }
+               if isMatch {
+                       availableSwAgentL = append(availableSwAgentL, swAgent)
+               }
+       }
+       return swAgentList

Review Comment:
   The variable like `${service_skywalking_system_oap_host}` is set by e2e, 
please refer the 
[doc](https://github.com/apache/skywalking-infra-e2e/blob/main/docs/en/setup/Configuration-File.md#resource-export).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to