fix(client): add checking on empty config in the gRPC handler (#307)

This commit is contained in:
Givi Khojanashvili 2022-05-05 22:00:28 +04:00 committed by GitHub
parent c7e5e5c7c9
commit fbf778a221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,7 +171,10 @@ func (s *Server) Down(ctx context.Context, msg *proto.DownRequest) (*proto.DownR
}
// Status starts engine work in the daemon.
func (s *Server) Status(ctx context.Context, msg *proto.StatusRequest) (*proto.StatusResponse, error) {
func (s *Server) Status(
ctx context.Context,
msg *proto.StatusRequest,
) (*proto.StatusResponse, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
@ -184,23 +187,30 @@ func (s *Server) Status(ctx context.Context, msg *proto.StatusRequest) (*proto.S
}
// GetConfig of the daemon.
func (s *Server) GetConfig(ctx context.Context, msg *proto.GetConfigRequest) (*proto.GetConfigResponse, error) {
func (s *Server) GetConfig(
ctx context.Context,
msg *proto.GetConfigRequest,
) (*proto.GetConfigResponse, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
managementURL := s.managementURL
if managementURL == "" && s.config.ManagementURL != nil {
managementURL = s.config.ManagementURL.String()
}
adminURL := s.adminURL
if s.config.AdminURL != nil {
adminURL = s.config.AdminURL.String()
}
preSharedKey := ""
preSharedKey := s.config.PreSharedKey
if preSharedKey != "" {
preSharedKey = "**********"
if s.config != nil {
if managementURL == "" && s.config.ManagementURL != nil {
managementURL = s.config.ManagementURL.String()
}
if s.config.AdminURL != nil {
adminURL = s.config.AdminURL.String()
}
preSharedKey = s.config.PreSharedKey
if preSharedKey != "" {
preSharedKey = "**********"
}
}
return &proto.GetConfigResponse{