mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-02-19 20:39:53 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b57d76d0c | ||
|
|
f42b979e18 | ||
|
|
8016789f7e | ||
|
|
fe3752e29c | ||
|
|
f7560dbe62 | ||
|
|
1de9257854 | ||
|
|
fd4eacda3c | ||
|
|
ee5679fab5 | ||
|
|
e23ddf5083 | ||
|
|
f48ff97943 | ||
|
|
fd93440017 | ||
|
|
9185dade92 | ||
|
|
2a692c48b0 | ||
|
|
ab1d7558e7 | ||
|
|
f71500b590 | ||
|
|
b41d15986c | ||
|
|
a7bee25a51 | ||
|
|
6604127c13 | ||
|
|
a1cd6d9ac9 | ||
|
|
8bd1672e07 | ||
|
|
1dc28da389 | ||
|
|
609eb49149 | ||
|
|
1e324f78b9 | ||
|
|
f9b03c8f13 | ||
|
|
1f6ad6752e | ||
|
|
f18348fd75 | ||
|
|
c6b22741d7 | ||
|
|
9b30561ccb | ||
|
|
74e30c1e9a | ||
|
|
b9233122fd | ||
|
|
ea46c35f71 | ||
|
|
23a8216e6d | ||
|
|
7eec26b194 | ||
|
|
97808d9365 | ||
|
|
d780fcaa4a | ||
|
|
d40bed4d3e | ||
|
|
ebbe41f4ef |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.git/
|
||||
/vendor/
|
||||
15
.travis.yml
15
.travis.yml
@@ -9,7 +9,18 @@ go:
|
||||
|
||||
script:
|
||||
- docker --version
|
||||
- go get -u github.com/golang/dep/cmd/dep && make vendor && make && make build
|
||||
# dep
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
# build locally and run locally
|
||||
- make clean && make vendor && make && ./bin/goldpinger --help
|
||||
|
||||
# build an image and run the image
|
||||
- make clean && make vendor && make build
|
||||
- docker images
|
||||
- make build-multistage
|
||||
- docker run `make version` --help
|
||||
|
||||
# build an image using the multistage builder
|
||||
- make clean && make build-multistage
|
||||
- docker images
|
||||
- docker run `make version` --help
|
||||
|
||||
@@ -5,17 +5,15 @@ FROM golang:1.11-alpine as builder
|
||||
RUN apk add --update git make bash
|
||||
RUN go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
# Get sources
|
||||
# Get dependencies
|
||||
|
||||
RUN go get github.com/bloomberg/goldpinger/cmd/goldpinger
|
||||
WORKDIR /go/src/github.com/bloomberg/goldpinger
|
||||
|
||||
# Install our dependencies
|
||||
|
||||
COPY Gopkg.toml Gopkg.lock Makefile ./
|
||||
RUN make vendor
|
||||
|
||||
# Build goldpinger
|
||||
|
||||
COPY . ./
|
||||
RUN make bin/goldpinger
|
||||
|
||||
# Build the asset container, copy over goldpinger
|
||||
|
||||
21
Gopkg.lock
generated
21
Gopkg.lock
generated
@@ -33,21 +33,6 @@
|
||||
pruneopts = "UT"
|
||||
revision = "3a771d992973f24aa725d07868b467d1ddfceafb"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:d76f06183572b1eabc33c586fae00b16430091ca48300ec9fdc8450f88df4c35"
|
||||
name = "github.com/bloomberg/goldpinger"
|
||||
packages = [
|
||||
"pkg/client",
|
||||
"pkg/client/operations",
|
||||
"pkg/goldpinger",
|
||||
"pkg/models",
|
||||
"pkg/restapi",
|
||||
"pkg/restapi/operations",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "0ebc4eecfa001237308b3c148619ec0f22f21ea1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:6f82cacd0af5921e99bf3f46748705239b36489464f4529a1589bc895764fb18"
|
||||
name = "github.com/docker/go-units"
|
||||
@@ -627,12 +612,6 @@
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/bloomberg/goldpinger/pkg/client",
|
||||
"github.com/bloomberg/goldpinger/pkg/client/operations",
|
||||
"github.com/bloomberg/goldpinger/pkg/goldpinger",
|
||||
"github.com/bloomberg/goldpinger/pkg/models",
|
||||
"github.com/bloomberg/goldpinger/pkg/restapi",
|
||||
"github.com/bloomberg/goldpinger/pkg/restapi/operations",
|
||||
"github.com/go-openapi/errors",
|
||||
"github.com/go-openapi/loads",
|
||||
"github.com/go-openapi/runtime",
|
||||
|
||||
21
Makefile
21
Makefile
@@ -1,14 +1,15 @@
|
||||
name ?= goldpinger
|
||||
version ?= 1.1.0
|
||||
version ?= 1.2.0
|
||||
bin ?= goldpinger
|
||||
pkg ?= "github.com/bloomberg/goldpinger"
|
||||
tag = $(name):$(version)
|
||||
goos ?= ${GOOS}
|
||||
namespace ?= ""
|
||||
files = $(shell find . -iname "*.go")
|
||||
|
||||
|
||||
bin/$(bin): $(files)
|
||||
PKG=${pkg} ARCH=amd64 VERSION=${version} BIN=${bin} ./build/build.sh
|
||||
GOOS=${goos} PKG=${pkg} ARCH=amd64 VERSION=${version} BIN=${bin} ./build/build.sh
|
||||
|
||||
clean:
|
||||
rm -rf ./vendor
|
||||
@@ -16,25 +17,29 @@ clean:
|
||||
|
||||
vendor:
|
||||
rm -rf ./vendor
|
||||
dep ensure -v
|
||||
dep ensure -v -vendor-only
|
||||
|
||||
swagger:
|
||||
swagger generate server -t pkg -f ./swagger.yml --exclude-main -A goldpinger && \
|
||||
swagger generate client -t pkg -f ./swagger.yml -A goldpinger
|
||||
|
||||
build-multistage:
|
||||
sudo docker build -t $(tag) -f ./Dockerfile .
|
||||
docker build -t $(tag) -f ./Dockerfile .
|
||||
|
||||
build: GOOS=linux
|
||||
build: bin/$(bin)
|
||||
sudo docker build -t $(tag) -f ./build/Dockerfile-simple .
|
||||
docker build -t $(tag) -f ./build/Dockerfile-simple .
|
||||
|
||||
tag:
|
||||
sudo docker tag $(tag) $(namespace)$(tag)
|
||||
docker tag $(tag) $(namespace)$(tag)
|
||||
|
||||
push:
|
||||
sudo docker push $(namespace)$(tag)
|
||||
docker push $(namespace)$(tag)
|
||||
|
||||
run:
|
||||
go run ./cmd/goldpinger/main.go
|
||||
|
||||
version:
|
||||
@echo $(tag)
|
||||
|
||||
.PHONY: clean vendor build-swagger build tag push run
|
||||
.PHONY: clean vendor swagger build build-multistage tag push run version
|
||||
|
||||
@@ -48,7 +48,7 @@ Note, that in order to guarantee correct versions of dependencies, the project [
|
||||
|
||||
## Building
|
||||
|
||||
The repo comes with two ways of building a `docker` image: compiling locally, and compiling using a multi-stage `Dockerfile` image.
|
||||
The repo comes with two ways of building a `docker` image: compiling locally, and compiling using a multi-stage `Dockerfile` image. :warning: Depending on your `docker` setup, you might need to prepend the commands below with `sudo`.
|
||||
|
||||
### Compiling using a multi-stage Dockerfile
|
||||
|
||||
@@ -185,7 +185,7 @@ You can also see [an example of using `kubeconfig` in the `./extras`](./extras/e
|
||||
|
||||
Once you have it running, you can hit any of the nodes (port 30080 in the example above) and see the UI.
|
||||
|
||||

|
||||

|
||||
|
||||
You can click on various nodes to gray out the clutter and see more information.
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ fi
|
||||
|
||||
export CGO_ENABLED=0
|
||||
export GOARCH="${ARCH}"
|
||||
export GOOS=${GOOS:-}
|
||||
|
||||
go build \
|
||||
-ldflags "-X 'main.Version=${VERSION}' -X 'main.Build=`date`'" \
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: goldpinger-serviceaccount
|
||||
namespace: default
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: goldpinger
|
||||
namespace: default
|
||||
labels:
|
||||
app: goldpinger
|
||||
spec:
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
spec:
|
||||
serviceAccount: "goldpinger-serviceaccount"
|
||||
containers:
|
||||
- name: goldpinger
|
||||
env:
|
||||
@@ -28,7 +38,7 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
image: "docker.io/mynamespace-replaceme/goldpinger:1.0.0"
|
||||
image: "docker.io/mynamespace-replaceme/goldpinger:1.1.0"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
@@ -37,6 +47,7 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: goldpinger
|
||||
namespace: default
|
||||
labels:
|
||||
app: goldpinger
|
||||
spec:
|
||||
@@ -47,3 +58,30 @@ spec:
|
||||
name: http
|
||||
selector:
|
||||
app: goldpinger
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: goldpinger-clusterrole
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- list
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: goldpinger-clusterrolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: goldpinger-clusterrole
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: goldpinger-serviceaccount
|
||||
namespace: default
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ metadata:
|
||||
name: goldpinger
|
||||
labels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
version: "1.1.0"
|
||||
spec:
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
version: "1.1.0"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
version: "1.1.0"
|
||||
spec:
|
||||
# if you'd like to use a secret to inject a kubeconfig, you can do it like this
|
||||
volumes:
|
||||
@@ -34,7 +34,7 @@ spec:
|
||||
# kubeconfig needs to match the location of what's injected in the secret
|
||||
# if not specified goldpinger will default to using in-cluster config
|
||||
- name: KUBECONFIG
|
||||
value: "./kube/config"
|
||||
value: "/.kube/config"
|
||||
# refresh interval (seconds) tells goldpinger to call every other instance with that frequency (set to 0 to disable)
|
||||
- name: REFRESH_INTERVAL
|
||||
value: "30"
|
||||
@@ -43,7 +43,7 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
image: "docker.io/mynamespace-replaceme/goldpinger:1.0.0"
|
||||
image: "docker.io/mynamespace-replaceme/goldpinger:1.1.0"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
|
||||
BIN
extras/screenshot-big.png
Normal file
BIN
extras/screenshot-big.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 823 KiB |
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package client
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
114
pkg/client/operations/healthz_parameters.go
Normal file
114
pkg/client/operations/healthz_parameters.go
Normal file
@@ -0,0 +1,114 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewHealthzParams creates a new HealthzParams object
|
||||
// with the default values initialized.
|
||||
func NewHealthzParams() *HealthzParams {
|
||||
|
||||
return &HealthzParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewHealthzParamsWithTimeout creates a new HealthzParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewHealthzParamsWithTimeout(timeout time.Duration) *HealthzParams {
|
||||
|
||||
return &HealthzParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewHealthzParamsWithContext creates a new HealthzParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewHealthzParamsWithContext(ctx context.Context) *HealthzParams {
|
||||
|
||||
return &HealthzParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewHealthzParamsWithHTTPClient creates a new HealthzParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewHealthzParamsWithHTTPClient(client *http.Client) *HealthzParams {
|
||||
|
||||
return &HealthzParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*HealthzParams contains all the parameters to send to the API endpoint
|
||||
for the healthz operation typically these are written to a http.Request
|
||||
*/
|
||||
type HealthzParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the healthz params
|
||||
func (o *HealthzParams) WithTimeout(timeout time.Duration) *HealthzParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the healthz params
|
||||
func (o *HealthzParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the healthz params
|
||||
func (o *HealthzParams) WithContext(ctx context.Context) *HealthzParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the healthz params
|
||||
func (o *HealthzParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the healthz params
|
||||
func (o *HealthzParams) WithHTTPClient(client *http.Client) *HealthzParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the healthz params
|
||||
func (o *HealthzParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *HealthzParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
103
pkg/client/operations/healthz_responses.go
Normal file
103
pkg/client/operations/healthz_responses.go
Normal file
@@ -0,0 +1,103 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/bloomberg/goldpinger/pkg/models"
|
||||
)
|
||||
|
||||
// HealthzReader is a Reader for the Healthz structure.
|
||||
type HealthzReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *HealthzReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewHealthzOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 503:
|
||||
result := NewHealthzServiceUnavailable()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewHealthzOK creates a HealthzOK with default headers values
|
||||
func NewHealthzOK() *HealthzOK {
|
||||
return &HealthzOK{}
|
||||
}
|
||||
|
||||
/*HealthzOK handles this case with default header values.
|
||||
|
||||
Health check report
|
||||
*/
|
||||
type HealthzOK struct {
|
||||
Payload *models.HealthCheckResults
|
||||
}
|
||||
|
||||
func (o *HealthzOK) Error() string {
|
||||
return fmt.Sprintf("[GET /healthz][%d] healthzOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *HealthzOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.HealthCheckResults)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewHealthzServiceUnavailable creates a HealthzServiceUnavailable with default headers values
|
||||
func NewHealthzServiceUnavailable() *HealthzServiceUnavailable {
|
||||
return &HealthzServiceUnavailable{}
|
||||
}
|
||||
|
||||
/*HealthzServiceUnavailable handles this case with default header values.
|
||||
|
||||
Unhealthy service
|
||||
*/
|
||||
type HealthzServiceUnavailable struct {
|
||||
Payload *models.HealthCheckResults
|
||||
}
|
||||
|
||||
func (o *HealthzServiceUnavailable) Error() string {
|
||||
return fmt.Sprintf("[GET /healthz][%d] healthzServiceUnavailable %+v", 503, o.Payload)
|
||||
}
|
||||
|
||||
func (o *HealthzServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.HealthCheckResults)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
@@ -94,6 +80,34 @@ func (a *Client) CheckServicePods(params *CheckServicePodsParams) (*CheckService
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Healthz The healthcheck endpoint provides detailed information about the health of a web service. If each of the components required by the service are healthy, then the service is considered healthy and will return a 200 OK response. If any of the components needed by the service are unhealthy, then a 503 Service Unavailable response will be provided.
|
||||
*/
|
||||
func (a *Client) Healthz(params *HealthzParams) (*HealthzOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewHealthzParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "healthz",
|
||||
Method: "GET",
|
||||
PathPattern: "/healthz",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{""},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &HealthzReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*HealthzOK), nil
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Ping return query stats
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -17,6 +17,7 @@ package goldpinger
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
apiclient "github.com/bloomberg/goldpinger/pkg/client"
|
||||
"github.com/bloomberg/goldpinger/pkg/models"
|
||||
@@ -162,6 +163,17 @@ func CheckAllPods(pods map[string]string) *models.CheckAllResults {
|
||||
return &result
|
||||
}
|
||||
|
||||
func HealthCheck() *models.HealthCheckResults {
|
||||
ok := true
|
||||
start := time.Now()
|
||||
result := models.HealthCheckResults{
|
||||
OK: &ok,
|
||||
DurationNs: time.Since(start).Nanoseconds(),
|
||||
GeneratedAt: strfmt.DateTime(start),
|
||||
}
|
||||
return &result
|
||||
}
|
||||
|
||||
func getClient(hostIP string) *apiclient.Goldpinger {
|
||||
host := fmt.Sprintf("%s:%d", hostIP, GoldpingerConfig.Port)
|
||||
transport := httptransport.New(host, "", nil)
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
74
pkg/models/health_check_results.go
Normal file
74
pkg/models/health_check_results.go
Normal file
@@ -0,0 +1,74 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// HealthCheckResults health check results
|
||||
// swagger:model HealthCheckResults
|
||||
type HealthCheckResults struct {
|
||||
|
||||
// o k
|
||||
OK *bool `json:"OK,omitempty"`
|
||||
|
||||
// duration ns
|
||||
DurationNs int64 `json:"duration-ns,omitempty"`
|
||||
|
||||
// generated at
|
||||
// Format: date-time
|
||||
GeneratedAt strfmt.DateTime `json:"generated-at,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this health check results
|
||||
func (m *HealthCheckResults) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateGeneratedAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HealthCheckResults) validateGeneratedAt(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.GeneratedAt) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("generated-at", "body", "date-time", m.GeneratedAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *HealthCheckResults) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *HealthCheckResults) UnmarshalBinary(b []byte) error {
|
||||
var res HealthCheckResults
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
@@ -70,6 +70,17 @@ func configureAPI(api *operations.GoldpingerAPI) http.Handler {
|
||||
return operations.NewCheckAllPodsOK().WithPayload(goldpinger.CheckNeighboursNeighbours())
|
||||
})
|
||||
|
||||
api.HealthzHandler = operations.HealthzHandlerFunc(
|
||||
func(params operations.HealthzParams) middleware.Responder {
|
||||
goldpinger.CountCall("received", "healthz")
|
||||
healthResult := goldpinger.HealthCheck()
|
||||
if *healthResult.OK {
|
||||
return operations.NewHealthzOK().WithPayload(healthResult)
|
||||
} else {
|
||||
return operations.NewHealthzServiceUnavailable().WithPayload(healthResult)
|
||||
}
|
||||
})
|
||||
|
||||
api.ServerShutdown = func() {}
|
||||
|
||||
return setupGlobalMiddleware(api.Serve(setupMiddlewares))
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package restapi
|
||||
@@ -72,6 +58,29 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/healthz": {
|
||||
"get": {
|
||||
"description": "The healthcheck endpoint provides detailed information about the health of a web service. If each of the components required by the service are healthy, then the service is considered healthy and will return a 200 OK response. If any of the components needed by the service are unhealthy, then a 503 Service Unavailable response will be provided.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"operationId": "healthz",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Health check report",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/HealthCheckResults"
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"description": "Unhealthy service",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/HealthCheckResults"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ping": {
|
||||
"get": {
|
||||
"description": "return query stats",
|
||||
@@ -172,6 +181,23 @@ func init() {
|
||||
"$ref": "#/definitions/PodResult"
|
||||
}
|
||||
},
|
||||
"HealthCheckResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"OK": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"duration-ns": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"generated-at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"PingResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -250,6 +276,29 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/healthz": {
|
||||
"get": {
|
||||
"description": "The healthcheck endpoint provides detailed information about the health of a web service. If each of the components required by the service are healthy, then the service is considered healthy and will return a 200 OK response. If any of the components needed by the service are unhealthy, then a 503 Service Unavailable response will be provided.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"operationId": "healthz",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Health check report",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/HealthCheckResults"
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"description": "Unhealthy service",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/HealthCheckResults"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/ping": {
|
||||
"get": {
|
||||
"description": "return query stats",
|
||||
@@ -350,6 +399,23 @@ func init() {
|
||||
"$ref": "#/definitions/PodResult"
|
||||
}
|
||||
},
|
||||
"HealthCheckResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"OK": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"duration-ns": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"generated-at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"PingResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
@@ -57,6 +43,9 @@ func NewGoldpingerAPI(spec *loads.Document) *GoldpingerAPI {
|
||||
CheckServicePodsHandler: CheckServicePodsHandlerFunc(func(params CheckServicePodsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation CheckServicePods has not yet been implemented")
|
||||
}),
|
||||
HealthzHandler: HealthzHandlerFunc(func(params HealthzParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation Healthz has not yet been implemented")
|
||||
}),
|
||||
PingHandler: PingHandlerFunc(func(params PingParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation Ping has not yet been implemented")
|
||||
}),
|
||||
@@ -95,6 +84,8 @@ type GoldpingerAPI struct {
|
||||
CheckAllPodsHandler CheckAllPodsHandler
|
||||
// CheckServicePodsHandler sets the operation handler for the check service pods operation
|
||||
CheckServicePodsHandler CheckServicePodsHandler
|
||||
// HealthzHandler sets the operation handler for the healthz operation
|
||||
HealthzHandler HealthzHandler
|
||||
// PingHandler sets the operation handler for the ping operation
|
||||
PingHandler PingHandler
|
||||
|
||||
@@ -168,6 +159,10 @@ func (o *GoldpingerAPI) Validate() error {
|
||||
unregistered = append(unregistered, "CheckServicePodsHandler")
|
||||
}
|
||||
|
||||
if o.HealthzHandler == nil {
|
||||
unregistered = append(unregistered, "HealthzHandler")
|
||||
}
|
||||
|
||||
if o.PingHandler == nil {
|
||||
unregistered = append(unregistered, "PingHandler")
|
||||
}
|
||||
@@ -280,6 +275,11 @@ func (o *GoldpingerAPI) initHandlerCache() {
|
||||
}
|
||||
o.handlers["GET"]["/check"] = NewCheckServicePods(o.context, o.CheckServicePodsHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/healthz"] = NewHealthz(o.context, o.HealthzHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
58
pkg/restapi/operations/healthz.go
Normal file
58
pkg/restapi/operations/healthz.go
Normal file
@@ -0,0 +1,58 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// HealthzHandlerFunc turns a function with the right signature into a healthz handler
|
||||
type HealthzHandlerFunc func(HealthzParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn HealthzHandlerFunc) Handle(params HealthzParams) middleware.Responder {
|
||||
return fn(params)
|
||||
}
|
||||
|
||||
// HealthzHandler interface for that can handle valid healthz params
|
||||
type HealthzHandler interface {
|
||||
Handle(HealthzParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewHealthz creates a new http.Handler for the healthz operation
|
||||
func NewHealthz(ctx *middleware.Context, handler HealthzHandler) *Healthz {
|
||||
return &Healthz{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*Healthz swagger:route GET /healthz healthz
|
||||
|
||||
The healthcheck endpoint provides detailed information about the health of a web service. If each of the components required by the service are healthy, then the service is considered healthy and will return a 200 OK response. If any of the components needed by the service are unhealthy, then a 503 Service Unavailable response will be provided.
|
||||
|
||||
*/
|
||||
type Healthz struct {
|
||||
Context *middleware.Context
|
||||
Handler HealthzHandler
|
||||
}
|
||||
|
||||
func (o *Healthz) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewHealthzParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
45
pkg/restapi/operations/healthz_parameters.go
Normal file
45
pkg/restapi/operations/healthz_parameters.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// NewHealthzParams creates a new HealthzParams object
|
||||
// no default values defined in spec.
|
||||
func NewHealthzParams() HealthzParams {
|
||||
|
||||
return HealthzParams{}
|
||||
}
|
||||
|
||||
// HealthzParams contains all the bound params for the healthz operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters healthz
|
||||
type HealthzParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewHealthzParams() beforehand.
|
||||
func (o *HealthzParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
102
pkg/restapi/operations/healthz_responses.go
Normal file
102
pkg/restapi/operations/healthz_responses.go
Normal file
@@ -0,0 +1,102 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
models "github.com/bloomberg/goldpinger/pkg/models"
|
||||
)
|
||||
|
||||
// HealthzOKCode is the HTTP code returned for type HealthzOK
|
||||
const HealthzOKCode int = 200
|
||||
|
||||
/*HealthzOK Health check report
|
||||
|
||||
swagger:response healthzOK
|
||||
*/
|
||||
type HealthzOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.HealthCheckResults `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewHealthzOK creates HealthzOK with default headers values
|
||||
func NewHealthzOK() *HealthzOK {
|
||||
|
||||
return &HealthzOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the healthz o k response
|
||||
func (o *HealthzOK) WithPayload(payload *models.HealthCheckResults) *HealthzOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the healthz o k response
|
||||
func (o *HealthzOK) SetPayload(payload *models.HealthCheckResults) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *HealthzOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HealthzServiceUnavailableCode is the HTTP code returned for type HealthzServiceUnavailable
|
||||
const HealthzServiceUnavailableCode int = 503
|
||||
|
||||
/*HealthzServiceUnavailable Unhealthy service
|
||||
|
||||
swagger:response healthzServiceUnavailable
|
||||
*/
|
||||
type HealthzServiceUnavailable struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.HealthCheckResults `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewHealthzServiceUnavailable creates HealthzServiceUnavailable with default headers values
|
||||
func NewHealthzServiceUnavailable() *HealthzServiceUnavailable {
|
||||
|
||||
return &HealthzServiceUnavailable{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the healthz service unavailable response
|
||||
func (o *HealthzServiceUnavailable) WithPayload(payload *models.HealthCheckResults) *HealthzServiceUnavailable {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the healthz service unavailable response
|
||||
func (o *HealthzServiceUnavailable) SetPayload(payload *models.HealthCheckResults) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *HealthzServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(503)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
84
pkg/restapi/operations/healthz_urlbuilder.go
Normal file
84
pkg/restapi/operations/healthz_urlbuilder.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// HealthzURL generates an URL for the healthz operation
|
||||
type HealthzURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *HealthzURL) WithBasePath(bp string) *HealthzURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *HealthzURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *HealthzURL) Build() (*url.URL, error) {
|
||||
var result url.URL
|
||||
|
||||
var _path = "/healthz"
|
||||
|
||||
_basePath := o._basePath
|
||||
result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *HealthzURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *HealthzURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *HealthzURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on HealthzURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on HealthzURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *HealthzURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package operations
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
// Copyright 2018 Bloomberg Finance L.P.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package restapi
|
||||
|
||||
32
swagger.yml
32
swagger.yml
@@ -83,6 +83,18 @@ definitions:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/CheckAllPodResult'
|
||||
HealthCheckResults:
|
||||
type: object
|
||||
properties:
|
||||
OK:
|
||||
type: boolean
|
||||
default: false
|
||||
generated-at:
|
||||
type: string
|
||||
format: date-time
|
||||
duration-ns:
|
||||
type: integer
|
||||
format: int64
|
||||
paths:
|
||||
/ping:
|
||||
get:
|
||||
@@ -120,3 +132,23 @@ paths:
|
||||
description: Success, return response
|
||||
schema:
|
||||
$ref: '#/definitions/CheckAllResults'
|
||||
/healthz:
|
||||
get:
|
||||
description: The healthcheck endpoint provides detailed information about
|
||||
the health of a web service. If each of the components required
|
||||
by the service are healthy, then the service is considered healthy
|
||||
and will return a 200 OK response. If any of the components needed
|
||||
by the service are unhealthy, then a 503 Service Unavailable
|
||||
response will be provided.
|
||||
produces:
|
||||
- application/json
|
||||
operationId: healthz
|
||||
responses:
|
||||
200:
|
||||
description: Health check report
|
||||
schema:
|
||||
$ref: '#/definitions/HealthCheckResults'
|
||||
503:
|
||||
description: Unhealthy service
|
||||
schema:
|
||||
$ref: '#/definitions/HealthCheckResults'
|
||||
|
||||
Reference in New Issue
Block a user