You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: globaldnsprovider_catalog_launcher.go
    path of file: ./repos/rancher/pkg/controllers/managementlegacy/globaldns
    
    the code of the file until where you have to start completion: package globaldns

import (
	"context"
	"fmt"
	"strings"

	v32 "github.com/rancher/rancher/pkg/apis/project.cattle.io/v3"

	"github.com/rancher/norman/types/convert"
	passwordutil "github.com/rancher/rancher/pkg/api/norman/store/password"
	"github.com/rancher/rancher/pkg/catalog/manager"
	cutils "github.com/rancher/rancher/pkg/catalog/utils"
	"github.com/rancher/rancher/pkg/controllers/management/rbac"
	v1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
	v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
	pv3 "github.com/rancher/rancher/pkg/generated/norman/project.cattle.io/v3"
	"github.com/rancher/rancher/pkg/namespace"
	"github.com/rancher/rancher/pkg/project"
	"github.com/rancher/rancher/pkg/settings"
	"github.com/rancher/rancher/pkg/types/config"
	"github.com/rancher/rancher/pkg/user"
	"github.com/sirupsen/log
    
func (n *ProviderCatalogLauncher) createUpdateExternalDNSApp(obj *v3.GlobalDnsProvider, answers map[string]string) (runtime.Object, error) {
	//check if provider already running for this GlobalDNSProvider.
	existingApp, err := n.getProviderIfAlreadyRunning(obj.Name)
	if err != nil {
		return nil, err
	}

	if existingApp != nil {
		var shouldUpdate bool
		var appToUpdate *pv3.App

		//check if answers should be updated
		if answersDiffer(existingApp.Spec.Answers, answers) {
			appToUpdate = existingApp.DeepCopy()
			updateAnswers(appToUpdate.Spec.Answers, answers)
			shouldUpdate = true
		}

		//check if ownerRef to GlobalDnsProvider is present; drop if yes
		if len(existingApp.OwnerReferences) > 0 {
			for _, ref := range existingApp.OwnerReferences {
				if ref.UID == obj.UID {
					if appToUpdate == nil {
						appToUpdate = existingApp.DeepCopy()
					}
					removeOwnerRef(appToUpdate, ref)
					shouldUpdate = true
					break
				}
			}
		}

		if shouldUpdate {
			_, err = n.Apps.Update(appToUpdate)
			if err != nil && !apierrors.IsAlreadyExists(err) {
				return nil, err
			}
		}
	} else {
		//create new app
		appCatalogID, err := n.getExternalDNSCatalogID(localClusterName)
		if err != nil {
			return nil, err
		}
		sysProject, err := n.getSystemProjectID()
		if err != nil {
			return nil, err
		}

		creator, err := n.userManager.EnsureUser(fmt.Sprintf("system://%s", localClusterName), "System account for Cluster "+localClusterName)
		if err != nil {
			return nil, err
		}
		toCreate := pv3.App{
			ObjectMeta: metav1.ObjectMeta{
				Annotations: map[string]string{cattleCreatorIDAnnotationKey: creator.Name},
				Name:        fmt.Sprintf("%s-%s", "systemapp", obj.Name),
				Namespace:   sysProject,
			},
			Spec: v32.AppSpec{
				ProjectName:     localClusterName + ":" + sysProject,
				TargetNamespace: namespace.GlobalNamespace,
				ExternalID:      appCatalogID,
				Answers:         answers,
			},
		}
		// Now create the App instance
		_, err = n.Apps.Create(&toCreate)
		if err != nil && !apierrors.IsAlreadyExists(err) {
			return nil, err
		}
	}
	return nil, nil
}