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: pd_start_script.go
    path of file: ./repos/tidb-operator/pkg/manager/member/startscript/v2
    
    the code of the file until where you have to start completion: // Copyright 2021 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with
    
func renderPDMSStartScript(tc *v1alpha1.TidbCluster, name string) (string, error) {
	m := &PDMSStartScriptModel{}
	tcName := tc.Name
	tcNS := tc.Namespace

	peerServiceName := controller.PDMSPeerMemberName(tcName, name)
	m.PDMSDomain = fmt.Sprintf("${PDMS_POD_NAME}.%s.%s.svc", peerServiceName, tcNS)
	if tc.Spec.ClusterDomain != "" {
		m.PDMSDomain = m.PDMSDomain + "." + tc.Spec.ClusterDomain
	}

	m.PDStartTimeout = tc.PDStartTimeout()

	preferPDAddressesOverDiscovery := slices.Contains(
		tc.Spec.StartScriptV2FeatureFlags, v1alpha1.StartScriptV2FeatureFlagPreferPDAddressesOverDiscovery)
	if preferPDAddressesOverDiscovery {
		pdAddressesWithSchemeAndPort := addressesWithSchemeAndPort(tc.Spec.PDAddresses, "", v1alpha1.DefaultPDClientPort)
		m.PDAddresses = strings.Join(pdAddressesWithSchemeAndPort, ",")
	}
	if len(m.PDAddresses) == 0 {
		if tc.AcrossK8s() {
			m.AcrossK8s = &AcrossK8sScriptModel{
				PDAddr:        fmt.Sprintf("%s://%s:%d", tc.Scheme(), controller.PDMemberName(tcName), v1alpha1.DefaultPDClientPort),
				DiscoveryAddr: fmt.Sprintf("%s-discovery.%s:10261", tcName, tcNS),
			}
			m.PDAddresses = "${result}" // get pd addr in subscript
		} else if tc.Heterogeneous() && tc.WithoutLocalPD() {
			m.PDAddresses = fmt.Sprintf("%s://%s:%d", tc.Scheme(), controller.PDMemberName(tc.Spec.Cluster.Name), v1alpha1.DefaultPDClientPort) // use pd of reference cluster
		} else {
			m.PDAddresses = fmt.Sprintf("%s://%s:%d", tc.Scheme(), controller.PDMemberName(tcName), v1alpha1.DefaultPDClientPort)
		}
	}

	m.ListenAddr = fmt.Sprintf("%s://0.0.0.0:%d", tc.Scheme(), v1alpha1.DefaultPDClientPort)

	// Need to use `PD_DOMAIN` to reuse the same logic with PD in function `pdWaitForDnsIpMatchSubScript`.
	m.AdvertiseListenAddr = fmt.Sprintf("%s://${PD_DOMAIN}:%d", tc.Scheme(), v1alpha1.DefaultPDClientPort)

	waitForDnsNameIpMatchOnStartup := slices.Contains(
		tc.Spec.StartScriptV2FeatureFlags, v1alpha1.StartScriptV2FeatureFlagWaitForDnsNameIpMatch)

	msStartScriptTpl := template.Must(
		template.Must(
			template.New("pdms-start-script").Parse(pdmsStartSubScript),
		).Parse(
			componentCommonScript +
				replacePdStartScriptCustomPorts(
					replacePdStartScriptDnsAwaitPart(waitForDnsNameIpMatchOnStartup,
						enableMicroServiceModeDynamic(name, pdmsStartScriptTplText)))))

	return renderTemplateFunc(msStartScriptTpl, m)
}