Skip to content

Commit 6cdcb36

Browse files
committed
change naming for runPod collector object
1 parent dfe5538 commit 6cdcb36

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

pkg/collect/run.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ func Run(c *Collector, runCollector *troubleshootv1beta2.Run) (CollectorResult,
5454
return RunPod(c, runPodCollector)
5555
}
5656

57-
func RunPod(c *Collector, runCollector *troubleshootv1beta2.RunPod) (CollectorResult, error) {
57+
func RunPod(c *Collector, runPodCollector *troubleshootv1beta2.RunPod) (CollectorResult, error) {
5858
ctx := context.Background()
5959

6060
client, err := kubernetes.NewForConfig(c.ClientConfig)
6161
if err != nil {
6262
return nil, errors.Wrap(err, "failed to create client from config")
6363
}
6464

65-
pod, err := runPodWithSpec(ctx, client, runCollector)
65+
pod, err := runPodWithSpec(ctx, client, runPodCollector)
6666
if err != nil {
6767
return nil, errors.Wrap(err, "failed to run pod")
6868
}
@@ -72,7 +72,7 @@ func RunPod(c *Collector, runCollector *troubleshootv1beta2.RunPod) (CollectorRe
7272
logger.Printf("Failed to delete pod %s: %v", pod.Name, err)
7373
}
7474
}()
75-
if runCollector.ImagePullSecret != nil && runCollector.ImagePullSecret.Data != nil {
75+
if runPodCollector.ImagePullSecret != nil && runPodCollector.ImagePullSecret.Data != nil {
7676
defer func() {
7777
for _, k := range pod.Spec.ImagePullSecrets {
7878
if err := client.CoreV1().Secrets(pod.Namespace).Delete(ctx, k.Name, metav1.DeleteOptions{}); err != nil {
@@ -81,11 +81,11 @@ func RunPod(c *Collector, runCollector *troubleshootv1beta2.RunPod) (CollectorRe
8181
}
8282
}()
8383
}
84-
if runCollector.Timeout == "" {
85-
return runWithoutTimeout(ctx, c, pod, runCollector)
84+
if runPodCollector.Timeout == "" {
85+
return runWithoutTimeout(ctx, c, pod, runPodCollector)
8686
}
8787

88-
timeout, err := time.ParseDuration(runCollector.Timeout)
88+
timeout, err := time.ParseDuration(runPodCollector.Timeout)
8989
if err != nil {
9090
return nil, errors.Wrap(err, "failed to parse timeout")
9191
}
@@ -97,7 +97,7 @@ func RunPod(c *Collector, runCollector *troubleshootv1beta2.RunPod) (CollectorRe
9797
defer cancel()
9898

9999
go func() {
100-
b, err := runWithoutTimeout(timeoutCtx, c, pod, runCollector)
100+
b, err := runWithoutTimeout(timeoutCtx, c, pod, runPodCollector)
101101
if err != nil {
102102
errCh <- err
103103
} else {
@@ -115,20 +115,20 @@ func RunPod(c *Collector, runCollector *troubleshootv1beta2.RunPod) (CollectorRe
115115
}
116116
}
117117

118-
func runPodWithSpec(ctx context.Context, client *kubernetes.Clientset, runCollector *troubleshootv1beta2.RunPod) (*corev1.Pod, error) {
118+
func runPodWithSpec(ctx context.Context, client *kubernetes.Clientset, runPodCollector *troubleshootv1beta2.RunPod) (*corev1.Pod, error) {
119119
podLabels := make(map[string]string)
120120
podLabels["troubleshoot-role"] = "run-collector"
121121

122122
namespace := "default"
123-
if runCollector.Namespace != "" {
124-
namespace = runCollector.Namespace
123+
if runPodCollector.Namespace != "" {
124+
namespace = runPodCollector.Namespace
125125
}
126126

127127
podName := "run-pod"
128-
if runCollector.CollectorName != "" {
129-
podName = runCollector.CollectorName
130-
} else if runCollector.Name != "" {
131-
podName = runCollector.Name
128+
if runPodCollector.CollectorName != "" {
129+
podName = runPodCollector.CollectorName
130+
} else if runPodCollector.Name != "" {
131+
podName = runPodCollector.Name
132132
}
133133

134134
pod := corev1.Pod{
@@ -141,11 +141,11 @@ func runPodWithSpec(ctx context.Context, client *kubernetes.Clientset, runCollec
141141
APIVersion: "v1",
142142
Kind: "Pod",
143143
},
144-
Spec: runCollector.PodSpec,
144+
Spec: runPodCollector.PodSpec,
145145
}
146146

147-
if runCollector.ImagePullSecret != nil && runCollector.ImagePullSecret.Data != nil {
148-
secretName, err := createSecret(ctx, client, pod.Namespace, runCollector.ImagePullSecret)
147+
if runPodCollector.ImagePullSecret != nil && runPodCollector.ImagePullSecret.Data != nil {
148+
secretName, err := createSecret(ctx, client, pod.Namespace, runPodCollector.ImagePullSecret)
149149
if err != nil {
150150
return nil, errors.Wrap(err, "failed to create secret")
151151
}
@@ -160,7 +160,7 @@ func runPodWithSpec(ctx context.Context, client *kubernetes.Clientset, runCollec
160160
return created, nil
161161
}
162162

163-
func runWithoutTimeout(ctx context.Context, c *Collector, pod *corev1.Pod, runCollector *troubleshootv1beta2.RunPod) (CollectorResult, error) {
163+
func runWithoutTimeout(ctx context.Context, c *Collector, pod *corev1.Pod, runPodCollector *troubleshootv1beta2.RunPod) (CollectorResult, error) {
164164
client, err := kubernetes.NewForConfig(c.ClientConfig)
165165
if err != nil {
166166
return nil, errors.Wrap(err, "failed create client from config")
@@ -188,9 +188,9 @@ func runWithoutTimeout(ctx context.Context, c *Collector, pod *corev1.Pod, runCo
188188

189189
output := NewResult()
190190

191-
collectorName := runCollector.Name
191+
collectorName := runPodCollector.Name
192192
if collectorName == "" {
193-
collectorName = runCollector.CollectorName
193+
collectorName = runPodCollector.CollectorName
194194
}
195195

196196
limits := troubleshootv1beta2.LogLimits{

0 commit comments

Comments
 (0)