func (c *gcpClient) ValidateDNSWriteAccess(reqLogger logr.Logger, cr *certmanv1alpha1.CertificateRequest) (bool, error) {
	var err error
	zone, err := c.getManagedZone(cr.Spec.ACMEDNSDomain)
	if err != nil {
		reqLogger.Error(err, "Unable to find appropriate managedzone")
		return false, err
	}
	dnsRecord := &dnsv1.ResourceRecordSet{
		Kind:    "dns#resourceRecordSet",
		Name:    fmt.Sprintf("%s.%s", cTypes.WriteValidationSubDomain, zone.DnsName),
		Rrdatas: []string{"txt_entry"},
		Ttl:     int64(resourceRecordTTL),
		Type:    "TXT",
	}
	err = c.upsertDnsRecord(zone, dnsRecord)
	if err != nil {
		return false, err
	}
	err = c.deleteDnsRecords(zone, []*dnsv1.ResourceRecordSet{dnsRecord})
	if err != nil {
		return false, err
	}
	return true, nil
}
ValidateDNSWriteAccess client to retrieve the baseDomain's hostedZoneOutput
and attempts to write a test TXT ResourceRecord to it. If successful, will return `true, nil`.
package gcp
import (
	"context"
	"fmt"
	"strings"
	"github.com/go-logr/logr"
	dnsv1 "google.golang.org/api/dns/v1"
	option "google.golang.org/api/option"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	"sigs.k8s.io/controller-runtime/pkg/client"
	certmanv1alpha1 "github.com/openshift/certman-operator/pkg/apis/certman/v1alpha1"
	cTypes "github.com/openshift/certman-operator/pkg/clients/types"
	"github.com/openshift/certman-operator/pkg/controller/utils"
)
const (
	resourceRecordTTL = 60
)
type gcpClient struct {
	client  dnsv1.Service
	project string
}
func (c *gcpClient) GetDNSName() string {
	return "Cloud DNS"
}
func (c *gcpClient) AnswerDNSChallenge(reqLogger logr.Logger, acmeChallengeToken string, domain string, cr *certmanv1alpha1.CertificateRequest) (fqdn string, err error) {
	fqdn = fmt.Sprintf("%s.%s", cTypes.AcmeChallengeSubDomain, domain)
	reqLogger.Info(fmt.Sprintf("fqdn acme challenge domain is %v", fqdn))
	var fqdnName string
	if !strings.HasSuffix(fqdn, ".") {
		fqdnName = fqdn + "."
	} else {
		fqdnName = fqdn
	}
	zone, err := c.getManagedZone(cr.Spec.ACMEDNSDomain)
	if err != nil {
		reqLogger.Error(err, "Unable to find appropriate managedzone")
		return "", err
	}
	dnsRecord := &dnsv1.ResourceRecordSet{
		Kind:    "dns#resourceRecordSet",
		Name:    fqdnName,
		Rrdatas: []string{fmt.Sprintf("\"%s\"", acmeChallengeToken)},
		Ttl:     int64(resourceRecordTTL),
		Type:    "TXT",
	}
	err = c.upsertDnsRecord(zone, dnsRecord)
	if err != nil {
		return "", err
	}
	return fqdn, nil
}