Skip to content

Commit 9d07e79

Browse files
Merge pull request openshift#682 from tnierman/fix_etcd_health_check
Allow any type of cluster ID when initializing backplane access
2 parents ba934c6 + 999fa59 commit 9d07e79

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmd/common/helpers.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
bplogin "github.com/openshift/backplane-cli/cmd/ocm-backplane/login"
88
bpconfig "github.com/openshift/backplane-cli/pkg/cli/config"
9+
"github.com/openshift/osdctl/pkg/utils"
910
corev1 "k8s.io/api/core/v1"
1011
"k8s.io/apimachinery/pkg/types"
1112
"k8s.io/client-go/kubernetes"
@@ -35,15 +36,24 @@ func UpdateSecret(kubeClient client.Client, secretName string, secretNamespace s
3536

3637
// If some elevationReasons are provided, then the config will be elevated with user backplane-cluster-admin
3738
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+
3848
bp, err := bpconfig.GetBackplaneConfiguration()
3949
if err != nil {
4050
return nil, nil, nil, fmt.Errorf("failed to load backplane-cli config: %v", err)
4151
}
4252
var kubeconfig *rest.Config
4353
if len(elevationReasons) == 0 {
44-
kubeconfig, err = bplogin.GetRestConfig(bp, clusterID)
54+
kubeconfig, err = bplogin.GetRestConfig(bp, cluster.ID())
4555
} else {
46-
kubeconfig, err = bplogin.GetRestConfigAsUser(bp, clusterID, "backplane-cluster-admin", elevationReasons...)
56+
kubeconfig, err = bplogin.GetRestConfigAsUser(bp, cluster.ID(), "backplane-cluster-admin", elevationReasons...)
4757
}
4858
if err != nil {
4959
return nil, nil, nil, err

0 commit comments

Comments
 (0)