functional/agent/handler.go
func (srv *Server) saveTLSAssets() error {
	if srv.Member.PeerCertPath != "" {
		if srv.Member.PeerCertData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerCertPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerCertPath, []byte(srv.Member.PeerCertData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerKeyPath != "" {
		if srv.Member.PeerKeyData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerKeyPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerKeyPath, []byte(srv.Member.PeerKeyData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerTrustedCAPath != "" {
		if srv.Member.PeerTrustedCAData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerTrustedCAPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerTrustedCAPath, []byte(srv.Member.PeerTrustedCAData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerCertPath != "" &&
		srv.Member.PeerKeyPath != "" &&
		srv.Member.PeerTrustedCAPath != "" {
		srv.lg.Info(
			"wrote",
			zap.String("peer-cert", srv.Member.PeerCertPath),
			zap.String("peer-key", srv.Member.PeerKeyPath),
			zap.String("peer-trusted-ca", srv.Member.PeerTrustedCAPath),
		)
	}

	if srv.Member.ClientCertPath != "" {
		if srv.Member.ClientCertData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientCertPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientCertPath, []byte(srv.Member.ClientCertData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientKeyPath != "" {
		if srv.Member.ClientKeyData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientKeyPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientKeyPath, []byte(srv.Member.ClientKeyData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientTrustedCAPath != "" {
		if srv.Member.ClientTrustedCAData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientTrustedCAPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientTrustedCAPath, []byte(srv.Member.ClientTrustedCAData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientCertPath != "" &&
		srv.Member.ClientKeyPath != "" &&
		srv.Member.ClientTrustedCAPath != "" {
		srv.lg.Info(
			"wrote",
			zap.String("client-cert", srv.Member.ClientCertPath),
			zap.String("client-key", srv.Member.ClientKeyPath),
			zap.String("client-trusted-ca", srv.Member.ClientTrustedCAPath),
		)
	}
	return nil
}
func (srv *Server) saveTLSAssets() error {
	if srv.Member.PeerCertPath != "" {
		if srv.Member.PeerCertData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerCertPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerCertPath, []byte(srv.Member.PeerCertData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerKeyPath != "" {
		if srv.Member.PeerKeyData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerKeyPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerKeyPath, []byte(srv.Member.PeerKeyData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerTrustedCAPath != "" {
		if srv.Member.PeerTrustedCAData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.PeerTrustedCAPath)
		}
		if err := ioutil.WriteFile(srv.Member.PeerTrustedCAPath, []byte(srv.Member.PeerTrustedCAData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.PeerCertPath != "" &&
		srv.Member.PeerKeyPath != "" &&
		srv.Member.PeerTrustedCAPath != "" {
		srv.lg.Info(
			"wrote",
			zap.String("peer-cert", srv.Member.PeerCertPath),
			zap.String("peer-key", srv.Member.PeerKeyPath),
			zap.String("peer-trusted-ca", srv.Member.PeerTrustedCAPath),
		)
	}

	if srv.Member.ClientCertPath != "" {
		if srv.Member.ClientCertData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientCertPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientCertPath, []byte(srv.Member.ClientCertData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientKeyPath != "" {
		if srv.Member.ClientKeyData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientKeyPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientKeyPath, []byte(srv.Member.ClientKeyData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientTrustedCAPath != "" {
		if srv.Member.ClientTrustedCAData == "" {
			return fmt.Errorf("got empty data for %q", srv.Member.ClientTrustedCAPath)
		}
		if err := ioutil.WriteFile(srv.Member.ClientTrustedCAPath, []byte(srv.Member.ClientTrustedCAData), 0644); err != nil {
			return err
		}
	}
	if srv.Member.ClientCertPath != "" &&
		srv.Member.ClientKeyPath != "" &&
		srv.Member.ClientTrustedCAPath != "" {
		srv.lg.Info(
			"wrote",
			zap.String("client-cert", srv.Member.ClientCertPath),
			zap.String("client-key", srv.Member.ClientKeyPath),
			zap.String("client-trusted-ca", srv.Member.ClientTrustedCAPath),
		)
	}
	return nil
}
func ( srv * Server ) saveTLSAssets ( ) error { if srv . Member . PeerCertPath != " " { if srv . Member . PeerCertData == " " { return fmt . Errorf ( " " , srv . Member . PeerCertPath ) } if err := ioutil . WriteFile ( srv . Member . PeerCertPath , [ ] byte ( srv . Member . PeerCertData ) , 0644 ) ; err != nil { return err } } if srv . Member . PeerKeyPath != " " { if srv . Member . PeerKeyData == " " { return fmt . Errorf ( " " , srv . Member . PeerKeyPath ) } if err := ioutil . WriteFile ( srv . Member . PeerKeyPath , [ ] byte ( srv . Member . PeerKeyData ) , 0644 ) ; err != nil { return err } } if srv . Member . PeerTrustedCAPath != " " { if srv . Member . PeerTrustedCAData == " " { return fmt . Errorf ( " " , srv . Member . PeerTrustedCAPath ) } if err := ioutil . WriteFile ( srv . Member . PeerTrustedCAPath , [ ] byte ( srv . Member . PeerTrustedCAData ) , 0644 ) ; err != nil { return err } } if srv . Member . PeerCertPath != " " && srv . Member . PeerKeyPath != " " && srv . Member . PeerTrustedCAPath != " " { srv . lg . Info ( " " , zap . String ( " " , srv . Member . PeerCertPath ) , zap . String ( " " , srv . Member . PeerKeyPath ) , zap . String ( " " , srv . Member . PeerTrustedCAPath ) , ) } if srv . Member . ClientCertPath != " " { if srv . Member . ClientCertData == " " { return fmt . Errorf ( " " , srv . Member . ClientCertPath ) } if err := ioutil . WriteFile ( srv . Member . ClientCertPath , [ ] byte ( srv . Member . ClientCertData ) , 0644 ) ; err != nil { return err } } if srv . Member . ClientKeyPath != " " { if srv . Member . ClientKeyData == " " { return fmt . Errorf ( " " , srv . Member . ClientKeyPath ) } if err := ioutil . WriteFile ( srv . Member . ClientKeyPath , [ ] byte ( srv . Member . ClientKeyData ) , 0644 ) ; err != nil { return err } } if srv . Member . ClientTrustedCAPath != " " { if srv . Member . ClientTrustedCAData == " " { return fmt . Errorf ( " " , srv . Member . ClientTrustedCAPath ) } if err := ioutil . WriteFile ( srv . Member . ClientTrustedCAPath , [ ] byte ( srv . Member . ClientTrustedCAData ) , 0644 ) ; err != nil { return err } } if srv . Member . ClientCertPath != " " && srv . Member . ClientKeyPath != " " && srv . Member . ClientTrustedCAPath != " " { srv . lg . Info ( " " , zap . String ( " " , srv . Member . ClientCertPath ) , zap . String ( " " , srv . Member . ClientKeyPath ) , zap . String ( " " , srv . Member . ClientTrustedCAPath ) , ) } return nil }
// if started with manual TLS, stores TLS assets
// from tester/client to disk before starting etcd process
if started with manual TLS stores TLS assets from tester / client to disk before starting etcd process