1
#pragma once
2

            
3
#include "envoy/admin/v3/config_dump.pb.h"
4
#include "envoy/buffer/buffer.h"
5
#include "envoy/config/endpoint/v3/endpoint_components.pb.h"
6
#include "envoy/http/codes.h"
7
#include "envoy/http/header_map.h"
8
#include "envoy/server/admin.h"
9
#include "envoy/server/instance.h"
10

            
11
#include "source/server/admin/config_tracker_impl.h"
12
#include "source/server/admin/handler_ctx.h"
13

            
14
#include "absl/strings/string_view.h"
15

            
16
namespace Envoy {
17
namespace Server {
18

            
19
class ConfigDumpHandler : public HandlerContextBase {
20

            
21
public:
22
  ConfigDumpHandler(ConfigTracker& config_tracker, Server::Instance& server);
23

            
24
  Http::Code handlerConfigDump(Http::ResponseHeaderMap& response_headers,
25
                               Buffer::Instance& response, AdminStream&) const;
26

            
27
private:
28
  absl::optional<std::pair<Http::Code, std::string>>
29
  addAllConfigToDump(envoy::admin::v3::ConfigDump& dump, const absl::optional<std::string>& mask,
30
                     const Matchers::StringMatcher& name_matcher, bool include_eds) const;
31
  /**
32
   * Add the config matching the passed resource to the passed config dump.
33
   * @return absl::nullopt on success, else the Http::Code and an error message that should be added
34
   * to the admin response.
35
   */
36
  absl::optional<std::pair<Http::Code, std::string>>
37
  addResourceToDump(envoy::admin::v3::ConfigDump& dump, const absl::optional<std::string>& mask,
38
                    const std::string& resource, const Matchers::StringMatcher& name_matcher,
39
                    bool include_eds) const;
40

            
41
  /**
42
   * Helper methods to add endpoints config
43
   */
44
  void addLbEndpoint(const Upstream::HostSharedPtr& host,
45
                     envoy::config::endpoint::v3::LocalityLbEndpoints& locality_lb_endpoint) const;
46

            
47
  ProtobufTypes::MessagePtr dumpEndpointConfigs(const Matchers::StringMatcher& name_matcher) const;
48

            
49
  ConfigTracker& config_tracker_;
50
};
51

            
52
} // namespace Server
53
} // namespace Envoy