github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/pkg/utils/openshift/config.go (about)

     1  package openshift
     2  
     3  import (
     4  	configv1 "github.com/openshift/api/config/v1"
     5  	configv1client "github.com/openshift/client-go/config/clientset/versioned"
     6  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     7  	"sigs.k8s.io/controller-runtime/pkg/client/config"
     8  	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
     9  )
    10  
    11  var (
    12  	logcfg = logf.Log.WithName("openshift-config")
    13  )
    14  
    15  func GetDnsConfig() *configv1.DNS {
    16  	dns := &configv1.DNS{}
    17  
    18  	config, err := config.GetConfig()
    19  	if err != nil {
    20  		logcfg.Error(err, "Error getting config: %v")
    21  	}
    22  	openshiftClient, err := configv1client.NewForConfig(config)
    23  	if err != nil {
    24  		logcfg.Error(err, "Error getting openshift client set: %v")
    25  	}
    26  
    27  	dns, err = openshiftClient.ConfigV1().DNSes().Get("cluster", metav1.GetOptions{})
    28  	if err != nil {
    29  		logcfg.Info("Unable to get cluster base domain, qdr-operator will be unable to include host name in requested certficates for exposed listeners")
    30  	}
    31  	return dns
    32  }