Skip to content

Commit 48beb30

Browse files
export context field from collector structs (#771)
1 parent e30d279 commit 48beb30

File tree

17 files changed

+31
-31
lines changed

17 files changed

+31
-31
lines changed

pkg/collect/ceph.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ type CollectCeph struct {
112112
Namespace string
113113
ClientConfig *rest.Config
114114
Client kubernetes.Interface
115-
ctx context.Context
115+
Context context.Context
116116
RBACErrors
117117
}
118118

@@ -164,7 +164,7 @@ func cephCommandExec(ctx context.Context, progressChan chan<- interface{}, c *Co
164164
}
165165

166166
rbacErrors := c.GetRBACErrors()
167-
execCollector := &CollectExec{execSpec, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.ctx, rbacErrors}
167+
execCollector := &CollectExec{execSpec, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.Context, rbacErrors}
168168

169169
results, err := execCollector.Collect(progressChan)
170170
if err != nil {

pkg/collect/collectd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type CollectCollectd struct {
1414
Namespace string
1515
ClientConfig *rest.Config
1616
Client kubernetes.Interface
17-
ctx context.Context
17+
Context context.Context
1818
RBACErrors
1919
}
2020

@@ -39,7 +39,7 @@ func (c *CollectCollectd) Collect(progressChan chan<- interface{}) (CollectorRes
3939
}
4040

4141
rbacErrors := c.GetRBACErrors()
42-
copyFromHostCollector := &CollectCopyFromHost{copyFromHost, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.ctx, rbacErrors}
42+
copyFromHostCollector := &CollectCopyFromHost{copyFromHost, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.Context, rbacErrors}
4343

4444
return copyFromHostCollector.Collect(progressChan)
4545
}

pkg/collect/configmap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type CollectConfigMap struct {
3333
Namespace string
3434
ClientConfig *rest.Config
3535
Client kubernetes.Interface
36-
ctx context.Context
36+
Context context.Context
3737
RBACErrors
3838
}
3939

@@ -50,7 +50,7 @@ func (c *CollectConfigMap) Collect(progressChan chan<- interface{}) (CollectorRe
5050

5151
configMaps := []corev1.ConfigMap{}
5252
if c.Collector.Name != "" {
53-
configMap, err := c.Client.CoreV1().ConfigMaps(c.Collector.Namespace).Get(c.ctx, c.Collector.Name, metav1.GetOptions{})
53+
configMap, err := c.Client.CoreV1().ConfigMaps(c.Collector.Namespace).Get(c.Context, c.Collector.Name, metav1.GetOptions{})
5454
if err != nil {
5555
if kuberneteserrors.IsNotFound(err) {
5656
filePath, encoded, err := configMapToOutput(c.Collector, nil, c.Collector.Name)
@@ -64,7 +64,7 @@ func (c *CollectConfigMap) Collect(progressChan chan<- interface{}) (CollectorRe
6464
}
6565
configMaps = append(configMaps, *configMap)
6666
} else if len(c.Collector.Selector) > 0 {
67-
cms, err := listConfigMapsForSelector(c.ctx, c.Client, c.Collector.Namespace, c.Collector.Selector)
67+
cms, err := listConfigMapsForSelector(c.Context, c.Client, c.Collector.Namespace, c.Collector.Selector)
6868
if err != nil {
6969
output.SaveResult(c.BundlePath, GetConfigMapErrorsFileName(c.Collector), marshalErrors([]string{err.Error()}))
7070
return output, nil

pkg/collect/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type CollectCopy struct {
2626
Namespace string
2727
ClientConfig *rest.Config
2828
Client kubernetes.Interface
29-
ctx context.Context
29+
Context context.Context
3030
RBACErrors
3131
}
3232

pkg/collect/copy_from_host.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type CollectCopyFromHost struct {
3232
Namespace string
3333
ClientConfig *rest.Config
3434
Client kubernetes.Interface
35-
ctx context.Context
35+
Context context.Context
3636
RBACErrors
3737
}
3838

@@ -69,13 +69,13 @@ func (c *CollectCopyFromHost) Collect(progressChan chan<- interface{}) (Collecto
6969
namespace, _, _ = kubeconfig.Namespace()
7070
}
7171

72-
_, cleanup, err := copyFromHostCreateDaemonSet(c.ctx, c.Client, c.Collector, hostDir, namespace, "troubleshoot-copyfromhost-", labels)
72+
_, cleanup, err := copyFromHostCreateDaemonSet(c.Context, c.Client, c.Collector, hostDir, namespace, "troubleshoot-copyfromhost-", labels)
7373
defer cleanup()
7474
if err != nil {
7575
return nil, errors.Wrap(err, "create daemonset")
7676
}
7777

78-
childCtx, cancel := context.WithCancel(c.ctx)
78+
childCtx, cancel := context.WithCancel(c.Context)
7979
defer cancel()
8080

8181
timeoutCtx := context.Background()

pkg/collect/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type CollectData struct {
1616
Namespace string
1717
ClientConfig *rest.Config
1818
Client kubernetes.Interface
19-
ctx context.Context
19+
Context context.Context
2020
RBACErrors
2121
}
2222

pkg/collect/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type CollectExec struct {
2222
Namespace string
2323
ClientConfig *rest.Config
2424
Client kubernetes.Interface
25-
ctx context.Context
25+
Context context.Context
2626
RBACErrors
2727
}
2828

pkg/collect/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type CollectLogs struct {
2222
Namespace string
2323
ClientConfig *rest.Config
2424
Client kubernetes.Interface
25-
ctx context.Context
25+
Context context.Context
2626
SinceTime *time.Time
2727
RBACErrors
2828
}

pkg/collect/longhorn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type CollectLonghorn struct {
3535
Namespace string
3636
ClientConfig *rest.Config
3737
Client kubernetes.Interface
38-
ctx context.Context
38+
Context context.Context
3939
RBACErrors
4040
}
4141

@@ -221,7 +221,7 @@ func (c *CollectLonghorn) Collect(progressChan chan<- interface{}) (CollectorRes
221221
}
222222

223223
rbacErrors := c.GetRBACErrors()
224-
logsCollector := &CollectLogs{logsCollectorSpec, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.ctx, nil, rbacErrors}
224+
logsCollector := &CollectLogs{logsCollectorSpec, c.BundlePath, c.Namespace, c.ClientConfig, c.Client, c.Context, nil, rbacErrors}
225225

226226
logs, err := logsCollector.Collect(progressChan)
227227
if err != nil {

pkg/collect/mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type CollectMysql struct {
2020
Namespace string
2121
ClientConfig *rest.Config
2222
Client kubernetes.Interface
23-
ctx context.Context
23+
Context context.Context
2424
RBACErrors
2525
}
2626

0 commit comments

Comments
 (0)