Skip to content

Commit

Permalink
bring in changes from local gloo
Browse files Browse the repository at this point in the history
  • Loading branch information
jbohanon committed Jun 14, 2024
1 parent a3ab92d commit 514e714
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions testutils/kube/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"io"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

Expand Down Expand Up @@ -42,7 +42,7 @@ func CurlWithEphemeralPod(ctx context.Context, logger io.Writer, kubeContext, fr
func FindPodNameByLabel(cfg *rest.Config, ctx context.Context, ns, labelSelector string) string {
clientset, err := kubernetes.NewForConfig(cfg)
Expect(err).NotTo(HaveOccurred())
pl, err := clientset.CoreV1().Pods(ns).List(ctx, v1.ListOptions{LabelSelector: labelSelector})
pl, err := clientset.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
Expect(err).NotTo(HaveOccurred())
Expect(pl.Items).NotTo(BeEmpty())
return pl.Items[0].GetName()
Expand Down
16 changes: 12 additions & 4 deletions testutils/kube/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ func ExecFromEphemeralPod(ctx context.Context, params EphemeralPodParams) (strin
// we will use the same params but just switch out the args for the
// different commands we execute.
kParams := kubectl.NewParams(createargs...)
kParams.Stdin = params.Stdin
kParams.Stdout = params.Stdout
kParams.Stderr = params.Stderr
kParams.Env = params.Env
if params.Stdin != nil {
kParams.Stdin = params.Stdin
}
if params.Stdout != nil {
kParams.Stdout = params.Stdout
}
if params.Stderr != nil {
kParams.Stderr = params.Stderr
}
if params.Env != nil {
kParams.Env = params.Env
}

// Execute curl commands from the same pod each time to avoid creating a burdensome number of ephemeral pods.
// create the curl pod; we do this every time and it will only work the first time, so ignore failures
Expand Down
4 changes: 3 additions & 1 deletion testutils/kube/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ func mustExecute(ctx context.Context, params KubectlParams) string {
}

func execute(ctx context.Context, params KubectlParams) (string, error) {
params.KubectlCmdParams.Args = append([]string{"--context", params.KubeContext}, params.KubectlCmdParams.Args...)
if params.KubeContext != "" {
params.KubectlCmdParams.Args = append([]string{"--context", params.KubeContext}, params.KubectlCmdParams.Args...)
}
fmt.Fprintf(params.Logger, "Executing: kubectl %v \n", params.KubectlCmdParams.Args)
p := kubectl.NewParams()
p.Stdin = params.KubectlCmdParams.Stdin
Expand Down

0 comments on commit 514e714

Please sign in to comment.