Skip to content

Commit d5bbf85

Browse files
committed
MEDIUM: Add info/ endpoint
1 parent 45a3288 commit d5bbf85

13 files changed

+743
-92
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Application Options:
3535
--scheme= the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec
3636
--cleanup-timeout= grace period for which to wait before killing idle connections (default: 10s)
3737
--graceful-timeout= grace period for which to wait before shutting down the server (default: 15s)
38-
--max-header-size= controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body. (default: 1MiB)
38+
--max-header-size= controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size
39+
of the request body. (default: 1MiB)
3940
--socket-path= the unix socket to listen on (default: /var/run/data-plane.sock)
4041
--host= the IP to listen on (default: localhost) [$HOST]
4142
--port= the port to listen on for insecure connections, defaults to a random value [$PORT]
@@ -62,8 +63,9 @@ HAProxy options:
6263
-s, --restart-cmd= Restart command
6364
--reload-retention= Reload retention in days, every older reload id will be deleted (default: 1)
6465
-t, --transaction-dir= Path to the transaction directory (default: /tmp/haproxy)
65-
-n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix(default: 0)
66+
-n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix (default: 0)
6667
-m, --master-runtime= Path to the master Runtime API socket
68+
-i, --show-system-info Show system info on info endpoint
6769
6870
Logging options:
6971
--log-to=[stdout|file] Log target, can be stdout or file (default: stdout)

cmd/dataplaneapi/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func main() {
4545
if err != nil {
4646
log.Fatalln(err)
4747
}
48+
49+
dataplaneapi.BuildTime = BuildTime
50+
dataplaneapi.Version = fmt.Sprintf("%s %s%s", GitTag, GitCommit, GitDirty)
51+
4852
api := operations.NewDataPlaneAPI(swaggerSpec)
4953
server := dataplaneapi.NewServer(api)
5054
defer server.Shutdown()

cmd/dataplaneapi/version.go

-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,3 @@ var GitDirty = ".dirty"
1414

1515
//BuildTime ...
1616
var BuildTime = ""
17-
18-
//IngressControllerInfo console pretty print
19-
const IngressControllerInfo = "HAProxy Data Plane API"

configure_data_plane.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ import (
6565

6666
//go:generate swagger generate server --target ../../../../../../github.com/haproxytech --name controller --spec ../../../../../../../../haproxy-api/haproxy-open-api-spec/build/haproxy_spec.yaml --server-package controller --tags Stats --tags Information --tags Configuration --tags Discovery --tags Frontend --tags Backend --tags Bind --tags Server --tags TCPRequestRule --tags HTTPRequestRule --tags HTTPResponseRule --tags Acl --tags BackendSwitchingRule --tags ServerSwitchingRule --tags TCPResponseRule --skip-models --exclude-main
6767

68+
var Version string
69+
var BuildTime string
70+
6871
var haproxyOptions struct {
6972
ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg"`
7073
Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller"`
@@ -76,6 +79,7 @@ var haproxyOptions struct {
7679
TransactionDir string `short:"t" long:"transaction-dir" description:"Path to the transaction directory" default:"/tmp/haproxy"`
7780
BackupsNumber int `short:"n" long:"backups-number" description:"Number of backup configuration files you want to keep, stored in the config dir with version number suffix" default:"0"`
7881
MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket"`
82+
ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint"`
7983
}
8084

8185
var loggingOptions struct {
@@ -319,7 +323,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
319323
api.StatsGetStatsHandler = &handlers.GetStatsHandlerImpl{Client: client}
320324

321325
// setup info handler
322-
api.InformationGetHaproxyProcessInfoHandler = &handlers.GetInformationHandlerImpl{Client: client}
326+
api.InformationGetHaproxyProcessInfoHandler = &handlers.GetHaproxyProcessInfoHandlerImpl{Client: client}
323327

324328
// setup raw configuration handlers
325329
api.ConfigurationGetHAProxyConfigurationHandler = &handlers.GetRawConfigurationHandlerImpl{Client: client}
@@ -337,6 +341,9 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
337341
api.ReloadsGetReloadHandler = &handlers.GetReloadHandlerImpl{ReloadAgent: ra}
338342
api.ReloadsGetReloadsHandler = &handlers.GetReloadsHandlerImpl{ReloadAgent: ra}
339343

344+
// setup info handler
345+
api.InformationGetInfoHandler = &handlers.GetInfoHandlerImpl{SystemInfo: haproxyOptions.ShowSystemInfo, BuildTime: BuildTime, Version: Version}
346+
340347
// setup specification handler
341348
api.SpecificationGetSpecificationHandler = specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal interface{}) middleware.Responder {
342349
var m map[string]interface{}

embedded_spec.go

+195-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ require (
1212
github.com/go-openapi/strfmt v0.19.0
1313
github.com/go-openapi/swag v0.19.0
1414
github.com/go-openapi/validate v0.19.0
15-
github.com/haproxytech/client-native v1.2.2
15+
github.com/haproxytech/client-native v1.2.3
1616
github.com/haproxytech/config-parser v1.1.3
17-
github.com/haproxytech/models v1.2.1
17+
github.com/haproxytech/models v1.2.2
1818
github.com/jessevdk/go-flags v1.4.0
1919
github.com/rs/cors v1.6.0
2020
github.com/sirupsen/logrus v1.4.2
2121
golang.org/x/net v0.0.0-20190607181551-461777fb6f67
22+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894
2223
)

0 commit comments

Comments
 (0)