TUN-8727: extend client to include function to get cli configuration and tunnel configuration

This commit is contained in:
lneto 2024-12-03 09:14:59 +00:00
parent 60fe4a0800
commit 451f98e1d1
3 changed files with 29 additions and 8 deletions

View File

@ -64,7 +64,7 @@ type LogConfiguration struct {
} }
func (client *httpClient) GetLogConfiguration(ctx context.Context) (*LogConfiguration, error) { func (client *httpClient) GetLogConfiguration(ctx context.Context) (*LogConfiguration, error) {
response, err := client.GET(ctx, configurationEndpoint) response, err := client.GET(ctx, cliConfigurationEndpoint)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -153,6 +153,24 @@ func (client *httpClient) GetMetrics(ctx context.Context, writer io.Writer) erro
return copyToWriter(response, writer) return copyToWriter(response, writer)
} }
func (client *httpClient) GetTunnelConfiguration(ctx context.Context, writer io.Writer) error {
response, err := client.GET(ctx, tunnelConfigurationEndpoint)
if err != nil {
return err
}
return copyToWriter(response, writer)
}
func (client *httpClient) GetCliConfiguration(ctx context.Context, writer io.Writer) error {
response, err := client.GET(ctx, cliConfigurationEndpoint)
if err != nil {
return err
}
return copyToWriter(response, writer)
}
func copyToWriter(response *http.Response, writer io.Writer) error { func copyToWriter(response *http.Response, writer io.Writer) error {
defer response.Body.Close() defer response.Body.Close()
@ -171,4 +189,6 @@ type HTTPClient interface {
GetTunnelState(ctx context.Context) (*TunnelState, error) GetTunnelState(ctx context.Context) (*TunnelState, error)
GetSystemInformation(ctx context.Context, writer io.Writer) error GetSystemInformation(ctx context.Context, writer io.Writer) error
GetMetrics(ctx context.Context, writer io.Writer) error GetMetrics(ctx context.Context, writer io.Writer) error
GetCliConfiguration(ctx context.Context, writer io.Writer) error
GetTunnelConfiguration(ctx context.Context, writer io.Writer) error
} }

View File

@ -15,10 +15,11 @@ const (
tailMaxNumberOfLines = "10000" // maximum number of log lines from a virtual runtime (docker or kubernetes) tailMaxNumberOfLines = "10000" // maximum number of log lines from a virtual runtime (docker or kubernetes)
// Endpoints used by the diagnostic HTTP Client. // Endpoints used by the diagnostic HTTP Client.
configurationEndpoint = "diag/configuration" cliConfigurationEndpoint = "/diag/configuration"
tunnelStateEndpoint = "diag/tunnel" tunnelStateEndpoint = "/diag/tunnel"
systemInformationEndpoint = "diag/system" systemInformationEndpoint = "/diag/system"
memoryDumpEndpoint = "debug/pprof/heap" memoryDumpEndpoint = "debug/pprof/heap"
goroutineDumpEndpoint = "debug/pprof/goroutine" goroutineDumpEndpoint = "debug/pprof/goroutine"
metricsEndpoint = "metrics" metricsEndpoint = "metrics"
tunnelConfigurationEndpoint = "/config"
) )

View File

@ -56,7 +56,7 @@ func NewDiagnosticHandler(
} }
func (handler *Handler) InstallEndpoints(router *http.ServeMux) { func (handler *Handler) InstallEndpoints(router *http.ServeMux) {
router.HandleFunc(configurationEndpoint, handler.ConfigurationHandler) router.HandleFunc(cliConfigurationEndpoint, handler.ConfigurationHandler)
router.HandleFunc(tunnelStateEndpoint, handler.TunnelStateHandler) router.HandleFunc(tunnelStateEndpoint, handler.TunnelStateHandler)
router.HandleFunc(systemInformationEndpoint, handler.SystemHandler) router.HandleFunc(systemInformationEndpoint, handler.SystemHandler)
} }