Skip to content

Commit ee8574a

Browse files
committed
clusterproxy.GetSveltosKubernetesClient to get the client pointing to the managed cluster
1 parent df3c66e commit ee8574a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

internal/utils/debuggingconfigurations.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ import (
2424

2525
libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1"
2626
clusterproxy "github.com/projectsveltos/libsveltos/lib/clusterproxy"
27+
"github.com/go-logr/logr"
28+
"k8s.io/apimachinery/pkg/runtime"
2729
)
2830

31+
// k8sAccess is a struct that holds the client and other necessary fields like logger and scheme
32+
type k8sAccess struct {
33+
client client.Client
34+
logger logr.Logger
35+
scheme *runtime.Scheme
36+
}
37+
2938
// GetDebuggingConfiguration gets default DebuggingConfiguration in the specified namespace and cluster
3039
func (a *k8sAccess) GetDebuggingConfiguration(
3140
ctx context.Context,
@@ -41,7 +50,7 @@ func (a *k8sAccess) GetDebuggingConfiguration(
4150
if namespace == "" && clusterName == "" && clusterType == "" {
4251
c = a.client
4352
} else {
44-
c, err = clusterproxy.GetSveltosKubernetesClient(ctx, a.client, namespace, clusterName, clusterType)
53+
c, err = clusterproxy.GetSveltosKubernetesClient(ctx, a.logger, a.client, a.scheme, namespace, clusterName)
4554
if err != nil {
4655
return nil, err
4756
}
@@ -50,7 +59,6 @@ func (a *k8sAccess) GetDebuggingConfiguration(
5059
reqName := client.ObjectKey{
5160
Namespace: namespace,
5261
Name: clusterName,
53-
Type: clusterType,
5462
}
5563

5664
if err := c.Get(ctx, reqName, req); err != nil {
@@ -76,7 +84,7 @@ func (a *k8sAccess) UpdateDebuggingConfiguration(
7684
if namespace == "" && clusterName == "" && clusterType == "" {
7785
c = a.client
7886
} else {
79-
c, err = clusterproxy.GetSveltosKubernetesClient(ctx, a.client, namespace, clusterName, clusterType)
87+
c, err = clusterproxy.GetSveltosKubernetesClient(ctx, a.logger, a.client, a.scheme, namespace, clusterName)
8088
if err != nil {
8189
return err
8290
}
@@ -85,7 +93,6 @@ func (a *k8sAccess) UpdateDebuggingConfiguration(
8593
reqName := client.ObjectKey{
8694
Namespace: namespace,
8795
Name: clusterName,
88-
Type: clusterType,
8996
}
9097

9198
tmp := &libsveltosv1alpha1.DebuggingConfiguration{}

0 commit comments

Comments
 (0)