...

Source file src/github.com/linkerd/linkerd2/controller/webhook/util.go

Documentation: github.com/linkerd/linkerd2/controller/webhook

     1  package webhook
     2  
     3  import (
     4  	"fmt"
     5  
     6  	labels "github.com/linkerd/linkerd2/pkg/k8s"
     7  	corev1 "k8s.io/api/core/v1"
     8  )
     9  
    10  // GetProxyContainerPath gets the proxy container jsonpath of a pod relative to spec;
    11  // this path is required in webhooks because of how patches are created.
    12  func GetProxyContainerPath(spec corev1.PodSpec) string {
    13  	for i, c := range spec.Containers {
    14  		if c.Name == labels.ProxyContainerName {
    15  			return fmt.Sprintf("containers/%d", i)
    16  		}
    17  	}
    18  	for i, c := range spec.InitContainers {
    19  		if c.Name == labels.ProxyContainerName {
    20  			return fmt.Sprintf("initContainers/%d", i)
    21  		}
    22  	}
    23  	return ""
    24  }
    25  

View as plain text