This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-swck.git


The following commit(s) were added to refs/heads/master by this push:
     new d6d125a  Remove SwAgent default env JAVA_TOOL_OPTIONS. (#106)
d6d125a is described below

commit d6d125a6bf565d3dde1d6e581c0d1b80cc96a9b0
Author: weixiang1862 <652048...@qq.com>
AuthorDate: Sun Mar 10 11:36:26 2024 +0800

    Remove SwAgent default env JAVA_TOOL_OPTIONS. (#106)
---
 operator/apis/operator/v1alpha1/swagent_webhook.go | 24 ----------------------
 1 file changed, 24 deletions(-)

diff --git a/operator/apis/operator/v1alpha1/swagent_webhook.go 
b/operator/apis/operator/v1alpha1/swagent_webhook.go
index f153283..aac6bf7 100644
--- a/operator/apis/operator/v1alpha1/swagent_webhook.go
+++ b/operator/apis/operator/v1alpha1/swagent_webhook.go
@@ -18,9 +18,6 @@
 package v1alpha1
 
 import (
-       "strings"
-
-       corev1 "k8s.io/api/core/v1"
        "k8s.io/apimachinery/pkg/runtime"
        ctrl "sigs.k8s.io/controller-runtime"
        logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -108,7 +105,6 @@ func (r *SwAgent) setDefault() {
                        r.Spec.JavaSidecar.Args = 
append(r.Spec.JavaSidecar.Args, "-c")
                        r.Spec.JavaSidecar.Args = 
append(r.Spec.JavaSidecar.Args, "mkdir -p /sky/agent && cp -r 
/skywalking/agent/* /sky/agent")
                }
-               r.setOrAppendEnv("JAVA_TOOL_OPTIONS", " 
-javaagent:/sky/agent/skywalking-agent.jar")
 
                // default values for shared volume
                if len(r.Spec.SharedVolumeName) == 0 {
@@ -117,23 +113,3 @@ func (r *SwAgent) setDefault() {
 
        }
 }
-
-func (r *SwAgent) setOrAppendEnv(envKey string, envValue string) {
-       if !r.appendEnvIfExists(&r.Spec.JavaSidecar.Env, envKey, envValue) {
-               javaToolOptionsEnv := corev1.EnvVar{
-                       Name:  envKey,
-                       Value: envValue,
-               }
-               r.Spec.JavaSidecar.Env = append(r.Spec.JavaSidecar.Env, 
javaToolOptionsEnv)
-       }
-}
-
-func (r *SwAgent) appendEnvIfExists(envs *[]corev1.EnvVar, envKey string, 
envValue string) bool {
-       for _, env := range *envs {
-               if strings.EqualFold(env.Name, envKey) {
-                       env.Value += envValue
-                       return true
-               }
-       }
-       return false
-}

Reply via email to