Skip to content

Commit

Permalink
make daprd to be the first container of pod in injector (dapr#3150)
Browse files Browse the repository at this point in the history
* make daprd to be the first container of pod in injector

* remove unused json file which is committed by mistaken

Co-authored-by: Sky Ao <[email protected]>
  • Loading branch information
skyao and Sky Ao authored May 12, 2021
1 parent 09d0fd9 commit dba6701
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/injector/pod_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (i *injector) getPodPatchOperations(ar *v1.AdmissionReview,
value = []corev1.Container{*sidecarContainer}
} else {
envPatchOps = addDaprEnvVarsToContainers(pod.Spec.Containers)
path = "/spec/containers/-"
path = "/spec/containers/0"
value = sidecarContainer
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func addDaprEnvVarsToContainers(containers []corev1.Container) []PatchOperation
}
envPatchOps := make([]PatchOperation, 0, len(containers))
for i, container := range containers {
path := fmt.Sprintf("%s/%d/env", containersPath, i)
path := fmt.Sprintf("%s/%d/env", containersPath, i+1)
patchOps := getEnvPatchOperations(container.Env, portEnv, path)
envPatchOps = append(envPatchOps, patchOps...)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/injector/pod_patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestAddDaprEnvVarsToContainers(t *testing.T) {
expOps: []PatchOperation{
{
Op: "add",
Path: "/spec/containers/0/env",
Path: "/spec/containers/1/env",
Value: []corev1.EnvVar{
{
Name: userContainerDaprHTTPPortName,
Expand Down Expand Up @@ -260,15 +260,15 @@ func TestAddDaprEnvVarsToContainers(t *testing.T) {
expOps: []PatchOperation{
{
Op: "add",
Path: "/spec/containers/0/env/-",
Path: "/spec/containers/1/env/-",
Value: corev1.EnvVar{
Name: userContainerDaprHTTPPortName,
Value: strconv.Itoa(sidecarHTTPPort),
},
},
{
Op: "add",
Path: "/spec/containers/0/env/-",
Path: "/spec/containers/1/env/-",
Value: corev1.EnvVar{
Name: userContainerDaprGRPCPortName,
Value: strconv.Itoa(sidecarAPIGRPCPort),
Expand All @@ -295,7 +295,7 @@ func TestAddDaprEnvVarsToContainers(t *testing.T) {
expOps: []PatchOperation{
{
Op: "add",
Path: "/spec/containers/0/env/-",
Path: "/spec/containers/1/env/-",
Value: corev1.EnvVar{
Name: userContainerDaprHTTPPortName,
Value: strconv.Itoa(sidecarHTTPPort),
Expand Down

0 comments on commit dba6701

Please sign in to comment.