github.com/verrazzano/verrazzano@v1.7.0/cluster-operator/internal/k8s/adminclusterconfig.go (about) 1 // Copyright (c) 2021, 2022, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package k8s 5 6 import ( 7 "context" 8 "fmt" 9 10 "github.com/verrazzano/verrazzano/platform-operator/constants" 11 corev1 "k8s.io/api/core/v1" 12 "k8s.io/apimachinery/pkg/types" 13 clipkg "sigs.k8s.io/controller-runtime/pkg/client" 14 ) 15 16 // GetAPIServerURL gets the external URL of the API server provided by the user 17 func GetAPIServerURL(client clipkg.Client) (string, error) { 18 // Get the configmap which has the info needed to build the URL 19 var cm corev1.ConfigMap 20 nsn := types.NamespacedName{ 21 Namespace: constants.VerrazzanoMultiClusterNamespace, 22 Name: constants.AdminClusterConfigMapName, 23 } 24 if err := client.Get(context.TODO(), nsn, &cm); err != nil { 25 return "", fmt.Errorf("Failed to fetch configmap %s/%s, %v", nsn.Namespace, nsn.Name, err) 26 } 27 return cm.Data[constants.ServerDataKey], nil 28 }