|
6 | 6 |
|
7 | 7 | bplogin "github.com/openshift/backplane-cli/cmd/ocm-backplane/login" |
8 | 8 | bpconfig "github.com/openshift/backplane-cli/pkg/cli/config" |
| 9 | + "github.com/openshift/osdctl/pkg/utils" |
9 | 10 | corev1 "k8s.io/api/core/v1" |
10 | 11 | "k8s.io/apimachinery/pkg/types" |
11 | 12 | "k8s.io/client-go/kubernetes" |
@@ -35,15 +36,24 @@ func UpdateSecret(kubeClient client.Client, secretName string, secretNamespace s |
35 | 36 |
|
36 | 37 | // If some elevationReasons are provided, then the config will be elevated with user backplane-cluster-admin |
37 | 38 | func GetKubeConfigAndClient(clusterID string, elevationReasons ...string) (client.Client, *rest.Config, *kubernetes.Clientset, error) { |
| 39 | + ocmClient, err := utils.CreateConnection() |
| 40 | + if err != nil { |
| 41 | + return nil, nil, nil, fmt.Errorf("failed to create ocm client: %w", err) |
| 42 | + } |
| 43 | + cluster, err := utils.GetCluster(ocmClient, clusterID) |
| 44 | + if err != nil { |
| 45 | + return nil, nil, nil, fmt.Errorf("failed to retrieve cluster: %w", err) |
| 46 | + } |
| 47 | + |
38 | 48 | bp, err := bpconfig.GetBackplaneConfiguration() |
39 | 49 | if err != nil { |
40 | 50 | return nil, nil, nil, fmt.Errorf("failed to load backplane-cli config: %v", err) |
41 | 51 | } |
42 | 52 | var kubeconfig *rest.Config |
43 | 53 | if len(elevationReasons) == 0 { |
44 | | - kubeconfig, err = bplogin.GetRestConfig(bp, clusterID) |
| 54 | + kubeconfig, err = bplogin.GetRestConfig(bp, cluster.ID()) |
45 | 55 | } else { |
46 | | - kubeconfig, err = bplogin.GetRestConfigAsUser(bp, clusterID, "backplane-cluster-admin", elevationReasons...) |
| 56 | + kubeconfig, err = bplogin.GetRestConfigAsUser(bp, cluster.ID(), "backplane-cluster-admin", elevationReasons...) |
47 | 57 | } |
48 | 58 | if err != nil { |
49 | 59 | return nil, nil, nil, err |
|
0 commit comments