From 3a0103ed25009fa4fc8015fbbb80e3da16ff9ec6 Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Tue, 24 Dec 2024 11:15:27 +0100 Subject: [PATCH] Extract system info to its own method --- client/server/debug.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/client/server/debug.go b/client/server/debug.go index beb9b3dadc4..3c4967b4e41 100644 --- a/client/server/debug.go +++ b/client/server/debug.go @@ -181,17 +181,7 @@ func (s *Server) createArchive(bundlePath *os.File, req *proto.DebugBundleReques } if req.GetSystemInfo() { - if err := s.addRoutes(req, anonymizer, archive); err != nil { - log.Errorf("Failed to add routes to debug bundle: %v", err) - } - - if err := s.addInterfaces(req, anonymizer, archive); err != nil { - log.Errorf("Failed to add interfaces to debug bundle: %v", err) - } - - if err := s.addFirewallRules(req, anonymizer, archive); err != nil { - log.Errorf("Failed to add firewall rules to debug bundle: %v", err) - } + s.addSystemInfo(req, anonymizer, archive) } if err := s.addNetworkMap(req, anonymizer, archive); err != nil { @@ -214,6 +204,20 @@ func (s *Server) createArchive(bundlePath *os.File, req *proto.DebugBundleReques return nil } +func (s *Server) addSystemInfo(req *proto.DebugBundleRequest, anonymizer *anonymize.Anonymizer, archive *zip.Writer) { + if err := s.addRoutes(req, anonymizer, archive); err != nil { + log.Errorf("Failed to add routes to debug bundle: %v", err) + } + + if err := s.addInterfaces(req, anonymizer, archive); err != nil { + log.Errorf("Failed to add interfaces to debug bundle: %v", err) + } + + if err := s.addFirewallRules(req, anonymizer, archive); err != nil { + log.Errorf("Failed to add firewall rules to debug bundle: %v", err) + } +} + func (s *Server) addReadme(req *proto.DebugBundleRequest, archive *zip.Writer) error { if req.GetAnonymize() { readmeReader := strings.NewReader(readmeContent)