func (a *CustomNameAsExternalName) Initialize(ctx context.Context, mg resource.Managed) error {
	if meta.GetExternalName(mg) != "" {
		return nil
	}
	meta.SetExternalName(mg, mg.GetName()+".")
	return errors.Wrap(a.client.Update(ctx, mg), errUpdateManaged)
}
Initialize the given managed resource.
package dns
import (
	"context"
	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"github.com/mitchellh/copystructure"
	dns "google.golang.org/api/dns/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"github.com/crossplane/crossplane-runtime/pkg/errors"
	"github.com/crossplane/crossplane-runtime/pkg/meta"
	"github.com/crossplane/crossplane-runtime/pkg/resource"
	"github.com/crossplane/provider-gcp/apis/dns/v1alpha1"
)
const (
	errCheckUpToDate = "unable to determine if external resource is up to date"
	errUpdateManaged = "cannot update managed resource external name"
)
func LateInitializeSpec(spec *v1alpha1.ResourceRecordSetParameters, external dns.ResourceRecordSet) {
	if len(spec.SignatureRRDatas) == 0 && len(external.SignatureRrdatas) > 0 {
		spec.SignatureRRDatas = external.SignatureRrdatas
	}
}
func GenerateResourceRecordSet(name string, spec v1alpha1.ResourceRecordSetParameters, rrs *dns.ResourceRecordSet) {
	rrs.Kind = "dns#resourceRecordSet"  
	rrs.Name = name
	rrs.Rrdatas = spec.RRDatas
	rrs.Ttl = spec.TTL
	rrs.Type = spec.Type
	if spec.SignatureRRDatas != nil {
		rrs.SignatureRrdatas = spec.SignatureRRDatas
	}
}
func IsUpToDate(name string, spec *v1alpha1.ResourceRecordSetParameters, observed *dns.ResourceRecordSet) (bool, error) {
	generated, err := copystructure.Copy(observed)
	if err != nil {
		return true, errors.Wrap(err, errCheckUpToDate)
	}
	desired, ok := generated.(*dns.ResourceRecordSet)
	if !ok {
		return true, errors.New(errCheckUpToDate)
	}
	GenerateResourceRecordSet(name, *spec, desired)
	return cmp.Equal(desired, observed, cmpopts.EquateEmpty()), nil
}
type CustomNameAsExternalName struct{ client client.Client }
func NewCustomNameAsExternalName(c client.Client) *CustomNameAsExternalName {
	return &CustomNameAsExternalName{client: c}
}