Skip to content

Commit

Permalink
MEDIUM: Add info/ endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuraga committed Aug 21, 2019
1 parent 45a3288 commit d5bbf85
Show file tree
Hide file tree
Showing 13 changed files with 743 additions and 92 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Application Options:
--scheme= the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec
--cleanup-timeout= grace period for which to wait before killing idle connections (default: 10s)
--graceful-timeout= grace period for which to wait before shutting down the server (default: 15s)
--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)
--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)
--socket-path= the unix socket to listen on (default: /var/run/data-plane.sock)
--host= the IP to listen on (default: localhost) [$HOST]
--port= the port to listen on for insecure connections, defaults to a random value [$PORT]
Expand All @@ -62,8 +63,9 @@ HAProxy options:
-s, --restart-cmd= Restart command
--reload-retention= Reload retention in days, every older reload id will be deleted (default: 1)
-t, --transaction-dir= Path to the transaction directory (default: /tmp/haproxy)
-n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix(default: 0)
-n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix (default: 0)
-m, --master-runtime= Path to the master Runtime API socket
-i, --show-system-info Show system info on info endpoint
Logging options:
--log-to=[stdout|file] Log target, can be stdout or file (default: stdout)
Expand Down
4 changes: 4 additions & 0 deletions cmd/dataplaneapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func main() {
if err != nil {
log.Fatalln(err)
}

dataplaneapi.BuildTime = BuildTime
dataplaneapi.Version = fmt.Sprintf("%s %s%s", GitTag, GitCommit, GitDirty)

api := operations.NewDataPlaneAPI(swaggerSpec)
server := dataplaneapi.NewServer(api)
defer server.Shutdown()
Expand Down
3 changes: 0 additions & 3 deletions cmd/dataplaneapi/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ var GitDirty = ".dirty"

//BuildTime ...
var BuildTime = ""

//IngressControllerInfo console pretty print
const IngressControllerInfo = "HAProxy Data Plane API"
9 changes: 8 additions & 1 deletion configure_data_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ import (

//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

var Version string
var BuildTime string

var haproxyOptions struct {
ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg"`
Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller"`
Expand All @@ -76,6 +79,7 @@ var haproxyOptions struct {
TransactionDir string `short:"t" long:"transaction-dir" description:"Path to the transaction directory" default:"/tmp/haproxy"`
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"`
MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket"`
ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint"`
}

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

// setup info handler
api.InformationGetHaproxyProcessInfoHandler = &handlers.GetInformationHandlerImpl{Client: client}
api.InformationGetHaproxyProcessInfoHandler = &handlers.GetHaproxyProcessInfoHandlerImpl{Client: client}

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

// setup info handler
api.InformationGetInfoHandler = &handlers.GetInfoHandlerImpl{SystemInfo: haproxyOptions.ShowSystemInfo, BuildTime: BuildTime, Version: Version}

// setup specification handler
api.SpecificationGetSpecificationHandler = specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal interface{}) middleware.Responder {
var m map[string]interface{}
Expand Down
213 changes: 195 additions & 18 deletions embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ require (
github.com/go-openapi/strfmt v0.19.0
github.com/go-openapi/swag v0.19.0
github.com/go-openapi/validate v0.19.0
github.com/haproxytech/client-native v1.2.2
github.com/haproxytech/client-native v1.2.3
github.com/haproxytech/config-parser v1.1.3
github.com/haproxytech/models v1.2.1
github.com/haproxytech/models v1.2.2
github.com/jessevdk/go-flags v1.4.0
github.com/rs/cors v1.6.0
github.com/sirupsen/logrus v1.4.2
golang.org/x/net v0.0.0-20190607181551-461777fb6f67
golang.org/x/sys v0.0.0-20190422165155-953cdadca894
)
Loading

0 comments on commit d5bbf85

Please sign in to comment.