func injectEnvironmentTag(req *admissionv1.AdmissionRequest) ([]PatchOperation, error) {
	logger.Debug("Handling admission request for", req.Name)
	if req.Resource != podResource {
		logger.Warn("Expect resource to be", podResource)
		return nil, nil
	}
	raw := req.Object.Raw
	pod := corev1.Pod{}
	if _, _, err := universalDeserializer.Decode(raw, nil, &pod); err != nil {
		return nil, fmt.Errorf("could not deserialize pod object: %v", err)
	}
	envLabels := os.Getenv(CONF_ENV_LABEL)
	if envLabels == "" {
		logger.Fatal("Cannot determine env label !!")
	}
	envLabelList := strings.Split(envLabels, ",")
	envTag := ""
	for _, label := range envLabelList {
		if value, ok := pod.Labels[label]; ok {
			envTag = value
			break
		}
	}
	if envTag == "" {
		logger.Warn("No environment tag found on pod", getPodName(pod))
		return nil, nil
	}
	sidecarContainerIndex := -1
	for i, container := range pod.Spec.Containers {
		if container.Name == sidecarContainerName {
			sidecarContainerIndex = i
		}
	}
	if sidecarContainerIndex < 0 {
		logger.Warn("No sidecar container found on pod", getPodName(pod))
		return nil, nil
	}
	envVarIndex := -1
	for i, envVar := range pod.Spec.Containers[sidecarContainerIndex].Env {
		if envVar.Name == envVarName {
			envVarIndex = i
		}
	}
	var patches []PatchOperation
	if envVarIndex < 0 {
		patches = append(patches, PatchOperation{
			Op:    "add",
			Path:  fmt.Sprintf("/spec/containers/%d/env/0", sidecarContainerIndex),
			Value: corev1.EnvVar{Name: envVarName, Value: envTag},
		})
	} else {
		patches = append(patches, PatchOperation{
			Op:    "replace",
			Path:  fmt.Sprintf("/spec/containers/%d/env/%d/value", sidecarContainerIndex, envVarIndex),
			Value: envTag,
		})
	}
	logger.Info("Marked", getPodName(pod), "as", envTag)
	return patches, nil
}
injectEnvironmentTag read the environment tag from pod label, and save to the sidecar container as an environment
variable named `VIRTUAL_ENVIRONMENT_TAG`
package main
import (
	"alibaba.com/virtual-env-operator/pkg/shared/logger"
	"fmt"
	admissionv1 "k8s.io/api/admission/v1"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"net/http"
	"os"
	"path/filepath"
	"strings"
)
const (
	tlsDir               = `/run/secrets/tls`
	tlsCertFile          = `tls.crt`
	tlsKeyFile           = `tls.key`
	envVarName           = "VIRTUAL_ENVIRONMENT_TAG"
	sidecarContainerName = "istio-proxy"
)
var (
	podResource = metav1.GroupVersionResource{Version: "v1", Resource: "pods"}
	version     string
	buildTime   string
)