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

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. // 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() s.mutex.Lock()
defer s.mutex.Unlock() defer s.mutex.Unlock()
@ -184,24 +187,31 @@ func (s *Server) Status(ctx context.Context, msg *proto.StatusRequest) (*proto.S
} }
// GetConfig of the daemon. // 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() s.mutex.Lock()
defer s.mutex.Unlock() defer s.mutex.Unlock()
managementURL := s.managementURL managementURL := s.managementURL
adminURL := s.adminURL
preSharedKey := ""
if s.config != nil {
if managementURL == "" && s.config.ManagementURL != nil { if managementURL == "" && s.config.ManagementURL != nil {
managementURL = s.config.ManagementURL.String() managementURL = s.config.ManagementURL.String()
} }
adminURL := s.adminURL
if s.config.AdminURL != nil { if s.config.AdminURL != nil {
adminURL = s.config.AdminURL.String() adminURL = s.config.AdminURL.String()
} }
preSharedKey := s.config.PreSharedKey preSharedKey = s.config.PreSharedKey
if preSharedKey != "" { if preSharedKey != "" {
preSharedKey = "**********" preSharedKey = "**********"
} }
}
return &proto.GetConfigResponse{ return &proto.GetConfigResponse{
ManagementUrl: managementURL, ManagementUrl: managementURL,