func ApplyEtcdNodeInitArgs(e *v1alpha1.EtcdCluster, app *tAppV1.TApp) {
	// append init args
	for i := 0; i < int(app.Spec.Replicas); i++ {
		args := make(map[string]string)
		args["name"] = app.Name + "-" + fmt.Sprint(i)
		if helpers.IsClientSecure(e) {
			args["trusted-ca-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdCACertName)
			args["cert-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdServerCertName)
			args["key-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdServerKeyName)
		}
		args["listen-client-urls"] = fmt.Sprintf("%s://0.0.0.0:%d", helpers.SchemeForClient(e), func() int32 {
			if e.Spec.ClientPort != nil {
				return *e.Spec.ClientPort
			}
			return constants.EtcdDefaultClientPort
		}())
		args["advertise-client-urls"] = strings.Join(helpers.AdvertiseClientURLs(e), ",")

		if i == 0 {
			args["initial-cluster-state"] = "new"
			args["initial-cluster-token"] = e.Namespace + "-" + e.Name
		} else {
			args["initial-cluster-state"] = "existing"
		}

		args["initial-advertise-peer-urls"] = fmt.Sprintf("%s://%s:%d", helpers.SchemeForPeer(e), fmt.Sprintf("%s-%d.%s.%s.svc.%s", app.Name, i, helpers.NameForHeadlessService(e), e.Namespace, helpers.ClusterDomain(e)), constants.EtcdDefaultPeerPort)

		for j := 0; j <= i; j++ {
			if j > 0 {
				args["initial-cluster"] = args["initial-cluster"] + ","
			}
			args["initial-cluster"] += fmt.Sprintf("%s=%s://%s:%d", app.Name+"-"+fmt.Sprint(j), helpers.SchemeForPeer(e), fmt.Sprintf("%s-%d.%s.%s.svc.%s", app.Name, j, helpers.NameForHeadlessService(e), e.Namespace, helpers.ClusterDomain(e)), constants.EtcdDefaultPeerPort)
		}

		if helpers.IsPeerSecure(e) {
			args["peer-trusted-ca-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdCACertName)
			args["peer-cert-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdPeerCertName)
			args["peer-key-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdPeerKeyName)

		}
		args["listen-peer-urls"] = fmt.Sprintf("%s://0.0.0.0:%d", helpers.SchemeForPeer(e), constants.EtcdDefaultPeerPort)

		// pv args
		if e.Spec.Template.PersistentVolumeClaimSpec != nil {
			args["data-dir"] = constants.EtcdDataVolumeMountPath
		}

		// auth args
		// - --peer-client-cert-auth=true
		// - --client-cert-auth=true
		app.Spec.TemplatePool[fmt.Sprint(i)].Spec.Containers[0].Args = flag.ToStringSlice(args, "--")
	}
}
// ApplyEtcdNodeInitArgs set the TApp container args with the EtcdCluster template
ApplyEtcdNodeInitArgs set the TApp container args with the EtcdCluster template
// ApplyEtcdNodeInitArgs set the TApp container args with the EtcdCluster template
func ApplyEtcdNodeInitArgs(e *v1alpha1.EtcdCluster, app *tAppV1.TApp) {
	for i := 0; i < int(app.Spec.Replicas); i++ {
		args := make(map[string]string)
		args["name"] = app.Name + "-" + fmt.Sprint(i)
		if helpers.IsClientSecure(e) {
			args["trusted-ca-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdCACertName)
			args["cert-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdServerCertName)
			args["key-file"] = path.Join(constants.EtcdServerTLSMountPath, secure.EtcdServerKeyName)
		}
		args["listen-client-urls"] = fmt.Sprintf("%s://0.0.0.0:%d", helpers.SchemeForClient(e), func() int32 {
			if e.Spec.ClientPort != nil {
				return *e.Spec.ClientPort
			}
			return constants.EtcdDefaultClientPort
		}())
		args["advertise-client-urls"] = strings.Join(helpers.AdvertiseClientURLs(e), ",")
		if i == 0 {
			args["initial-cluster-state"] = "new"
			args["initial-cluster-token"] = e.Namespace + "-" + e.Name
		} else {
			args["initial-cluster-state"] = "existing"
		}
		args["initial-advertise-peer-urls"] = fmt.Sprintf("%s://%s:%d", helpers.SchemeForPeer(e), fmt.Sprintf("%s-%d.%s.%s.svc.%s", app.Name, i, helpers.NameForHeadlessService(e), e.Namespace, helpers.ClusterDomain(e)), constants.EtcdDefaultPeerPort)
		for j := 0; j <= i; j++ {
			if j > 0 {
				args["initial-cluster"] = args["initial-cluster"] + ","
			}
			args["initial-cluster"] += fmt.Sprintf("%s=%s://%s:%d", app.Name+"-"+fmt.Sprint(j), helpers.SchemeForPeer(e), fmt.Sprintf("%s-%d.%s.%s.svc.%s", app.Name, j, helpers.NameForHeadlessService(e), e.Namespace, helpers.ClusterDomain(e)), constants.EtcdDefaultPeerPort)
		}
		if helpers.IsPeerSecure(e) {
			args["peer-trusted-ca-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdCACertName)
			args["peer-cert-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdPeerCertName)
			args["peer-key-file"] = path.Join(constants.EtcdPeerTLSMountPath, secure.EtcdPeerKeyName)
		}
		args["listen-peer-urls"] = fmt.Sprintf("%s://0.0.0.0:%d", helpers.SchemeForPeer(e), constants.EtcdDefaultPeerPort)
		if e.Spec.Template.PersistentVolumeClaimSpec != nil {
			args["data-dir"] = constants.EtcdDataVolumeMountPath
		}
		app.Spec.TemplatePool[fmt.Sprint(i)].Spec.Containers[0].Args = flag.ToStringSlice(args, "--")
	}
}
func ApplyEtcdNodeInitArgs ( e * v1alpha1 . EtcdCluster , app * tAppV1 . TApp ) { for i := 0 ; i < int ( app . Spec . Replicas ) ; i ++ { args := make ( map [ string ] string ) args [ " " ] = app . Name + " " + fmt . Sprint ( i ) if helpers . IsClientSecure ( e ) { args [ " " ] = path . Join ( constants . EtcdServerTLSMountPath , secure . EtcdCACertName ) args [ " " ] = path . Join ( constants . EtcdServerTLSMountPath , secure . EtcdServerCertName ) args [ " " ] = path . Join ( constants . EtcdServerTLSMountPath , secure . EtcdServerKeyName ) } args [ " " ] = fmt . Sprintf ( " " , helpers . SchemeForClient ( e ) , func ( ) int32 { if e . Spec . ClientPort != nil { return * e . Spec . ClientPort } return constants . EtcdDefaultClientPort } ( ) ) args [ " " ] = strings . Join ( helpers . AdvertiseClientURLs ( e ) , " " ) if i == 0 { args [ " " ] = " " args [ " " ] = e . Namespace + " " + e . Name } else { args [ " " ] = " " } args [ " " ] = fmt . Sprintf ( " " , helpers . SchemeForPeer ( e ) , fmt . Sprintf ( " " , app . Name , i , helpers . NameForHeadlessService ( e ) , e . Namespace , helpers . ClusterDomain ( e ) ) , constants . EtcdDefaultPeerPort ) for j := 0 ; j <= i ; j ++ { if j > 0 { args [ " " ] = args [ " " ] + " " } args [ " " ] += fmt . Sprintf ( " " , app . Name + " " + fmt . Sprint ( j ) , helpers . SchemeForPeer ( e ) , fmt . Sprintf ( " " , app . Name , j , helpers . NameForHeadlessService ( e ) , e . Namespace , helpers . ClusterDomain ( e ) ) , constants . EtcdDefaultPeerPort ) } if helpers . IsPeerSecure ( e ) { args [ " " ] = path . Join ( constants . EtcdPeerTLSMountPath , secure . EtcdCACertName ) args [ " " ] = path . Join ( constants . EtcdPeerTLSMountPath , secure . EtcdPeerCertName ) args [ " " ] = path . Join ( constants . EtcdPeerTLSMountPath , secure . EtcdPeerKeyName ) } args [ " " ] = fmt . Sprintf ( " " , helpers . SchemeForPeer ( e ) , constants . EtcdDefaultPeerPort ) if e . Spec . Template . PersistentVolumeClaimSpec != nil { args [ " " ] = constants . EtcdDataVolumeMountPath } app . Spec . TemplatePool [ fmt . Sprint ( i ) ] . Spec . Containers [ 0 ] . Args = flag . ToStringSlice ( args , " " ) } }
ApplyEtcdNodeInitArgs set the TApp container args with the EtcdCluster template
ApplyEtcdNodeInitArgs set the TApp container args with the EtcdCluster template
// append init args // pv args // auth args // - --peer-client-cert-auth=true // - --client-cert-auth=true