Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
debugger: Expose all feature flags via /debug/feature-flags endpoint (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
draychev authored Oct 27, 2020
1 parent 92b5699 commit 7df16e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
19 changes: 19 additions & 0 deletions pkg/debugger/feature_flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package debugger

import (
"encoding/json"
"fmt"
"net/http"

"github.com/openservicemesh/osm/pkg/featureflags"
)

func (ds debugServer) getFeatureFlags() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if featureFlagsJSON, err := json.Marshal(featureflags.Features); err != nil {
log.Error().Err(err).Msgf("Error marshaling feature flags struct: %+v", featureflags.Features)
} else {
_, _ = fmt.Fprint(w, string(featureFlagsJSON))
}
})
}
14 changes: 8 additions & 6 deletions pkg/debugger/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
// GetHandlers implements DebugServer interface and returns the rest of URLs and the handling functions.
func (ds debugServer) GetHandlers() map[string]http.Handler {
handlers := map[string]http.Handler{
"/debug/certs": ds.getCertHandler(),
"/debug/xds": ds.getXDSHandler(),
"/debug/proxy": ds.getProxies(),
"/debug/policies": ds.getSMIPoliciesHandler(),
"/debug/config": ds.getOSMConfigHandler(),
"/debug/namespaces": ds.getMonitoredNamespacesHandler(),
"/debug/certs": ds.getCertHandler(),
"/debug/xds": ds.getXDSHandler(),
"/debug/proxy": ds.getProxies(),
"/debug/policies": ds.getSMIPoliciesHandler(),
"/debug/config": ds.getOSMConfigHandler(),
"/debug/namespaces": ds.getMonitoredNamespacesHandler(),
"/debug/feature-flags": ds.getFeatureFlags(),

// Pprof handlers
"/debug/pprof/": http.HandlerFunc(pprof.Index),
"/debug/pprof/cmdline": http.HandlerFunc(pprof.Cmdline),
Expand Down

0 comments on commit 7df16e9

Please sign in to comment.