Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kschoche committed Feb 24, 2021
1 parent c70fe2d commit bcf7a24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions connect-inject/container_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type initContainerCommandUpstreamData struct {

// containerInitCopyContainer returns the init container spec for the copy container which places
// the consul binary into the shared volume.
func (h *Handler) containerInitCopyContainer() (corev1.Container, error) {
func (h *Handler) containerInitCopyContainer() corev1.Container {
// Copy the Consul binary from the image to the shared volume.
cmd := "cp /bin/consul /consul/connect-inject/consul"
return corev1.Container{
Expand All @@ -80,7 +80,7 @@ func (h *Handler) containerInitCopyContainer() (corev1.Container, error) {
},
},
Command: []string{"/bin/sh", "-ec", cmd},
}, nil
}
}

// containerInit returns the init container spec for registering the Consul
Expand Down
3 changes: 1 addition & 2 deletions connect-inject/container_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,7 @@ func TestHandlerContainerInit_MeshGatewayModeErrors(t *testing.T) {
func TestHandlerContainerInitCopyContainer(t *testing.T) {
require := require.New(t)
h := Handler{}
container, err := h.containerInitCopyContainer()
require.NoError(err)
container := h.containerInitCopyContainer()
actual := strings.Join(container.Command, " ")
require.Contains(actual, `cp /bin/consul /consul/connect-inject/consul`)
}
11 changes: 2 additions & 9 deletions connect-inject/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,8 @@ func (h *Handler) Mutate(req *v1beta1.AdmissionRequest) *v1beta1.AdmissionRespon
}

// Add the init container which copies the consul binary.
initCopyContainer, err := h.containerInitCopyContainer()
if err != nil {
h.Log.Error("Error configuring injection init copy container", "err", err, "Request Name", req.Name)
return &v1beta1.AdmissionResponse{
Result: &metav1.Status{
Message: fmt.Sprintf("Error configuring injection init copy container: %s", err),
},
}
}
initCopyContainer := h.containerInitCopyContainer()

// Add the init container that registers the service and sets up
// the Envoy configuration.
initContainer, err := h.containerInit(&pod, req.Namespace)
Expand Down

0 comments on commit bcf7a24

Please sign in to comment.