37 Commits
1.1.0 ... 1.2.0

Author SHA1 Message Date
Mikolaj Pawlikowski
1b57d76d0c Merge pull request #42 from seeker89/version-bump
Version bump to 1.2.0
2019-01-04 15:36:11 +00:00
Mikolaj Pawlikowski
f42b979e18 version bump to 1.2.0
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2019-01-03 13:06:02 -05:00
Mikolaj Pawlikowski
8016789f7e Merge pull request #29 from kaduev13/8-healthz-endpoint
Add simple healthz endpoint
2019-01-03 18:04:40 +00:00
Mikolaj Pawlikowski
fe3752e29c Merge branch 'master' into 8-healthz-endpoint 2019-01-03 17:55:53 +00:00
Mikolaj Pawlikowski
f7560dbe62 Merge pull request #41 from dannyk81/patch-1
fix typo in kubeconfig example and version bump
2019-01-02 16:50:31 +01:00
Danny Kulchinsky
1de9257854 fix typo and version bump
Signed-off-by: Danny Kulchinsky <danny.kul@gmail.com>
2019-01-02 10:24:04 -05:00
Mikolaj Pawlikowski
fd4eacda3c Merge branch 'master' into 8-healthz-endpoint 2019-01-02 10:58:21 +01:00
Mikolaj Pawlikowski
ee5679fab5 Merge pull request #38 from marcosdiez/better-serviceaccount-example
More complete example-serviceaccounts.yml, now with rbac rules
2018-12-27 22:36:48 +01:00
Marcos Diez
e23ddf5083 More complete example-serviceaccounts.yml, now with rbac rules
Signed-off-by: Marcos Diez <marcos@unitron.com.br>
2018-12-26 16:55:58 -02:00
Mikolaj Pawlikowski
f48ff97943 Merge branch 'master' into 8-healthz-endpoint 2018-12-21 18:59:29 +01:00
Mikolaj Pawlikowski
fd93440017 Merge pull request #36 from kaduev13/17-add-goos-to-build-process
Fix GOOS problems during simple docker build
2018-12-21 18:58:13 +01:00
Mikolaj Pawlikowski
9185dade92 derp - fixed travis
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-21 18:41:11 +01:00
Mikolaj Pawlikowski
2a692c48b0 Update travis to run locally, and from both docker builders
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-21 18:34:13 +01:00
Mikolaj Pawlikowski
ab1d7558e7 update Makefile, add make version target
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-21 18:28:24 +01:00
Ivan Kalita
f71500b590 Improve GOOS workaround in build.sh
According to #17.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-21 17:53:42 +01:00
Ivan Kalita
b41d15986c Fix GOOS problems during simple docker build
According to #17.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-21 16:54:49 +01:00
Mikolaj Pawlikowski
a7bee25a51 Merge pull request #35 from akhy/dockerfile-fix
fix Dockerfile to build from current workspace
2018-12-21 16:36:10 +01:00
Akhyar Amarullah
6604127c13 fix broken simple docker build
Signed-off-by: Akhyar Amarullah <akhyrul@gmail.com>
2018-12-21 21:53:47 +07:00
Akhyar Amarullah
a1cd6d9ac9 fix Dockerfile to build from current workspace
Signed-off-by: Akhyar Amarullah <akhyrul@gmail.com>
2018-12-21 21:23:45 +07:00
Ivan Kalita
8bd1672e07 Remove license header from healthz-related autogenerated files
According to #32.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-21 14:45:54 +01:00
Mikolaj Pawlikowski
1dc28da389 Merge branch 'master' into 8-healthz-endpoint 2018-12-21 14:42:48 +01:00
Mikolaj Pawlikowski
609eb49149 Merge pull request #34 from kaduev13/32-remove-license-from-autogenerated-files
Remove license header from autogenerated files
2018-12-21 14:42:34 +01:00
Ivan Kalita
1e324f78b9 Remove license header from autogenerated files
According to #32.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-21 14:28:44 +01:00
Mikolaj Pawlikowski
f9b03c8f13 Merge pull request #33 from seeker89/gopkg-lock
Clean up the Gopkg.lock file
2018-12-21 12:16:15 +01:00
Mikolaj Pawlikowski
1f6ad6752e clean up the Gopkg.lock file
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-21 05:45:18 -05:00
Mikolaj Pawlikowski
f18348fd75 Merge pull request #30 from kaduev13/15-remove-sudo-from-makefile
Remove sudo from docker-related Makefile targets
2018-12-21 10:32:22 +01:00
Mikolaj Pawlikowski
c6b22741d7 Update README.md
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-21 10:18:23 +01:00
Mikolaj Pawlikowski
9b30561ccb Add a note about sudo usage for beginners
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 21:34:14 +01:00
Mikolaj Pawlikowski
74e30c1e9a Merge branch 'master' into 15-remove-sudo-from-makefile 2018-12-20 21:20:26 +01:00
Mikolaj Pawlikowski
b9233122fd Merge pull request #31 from seeker89/screenshot
Cosmetic tweaks to the README
2018-12-20 21:20:02 +01:00
Mikolaj Pawlikowski
ea46c35f71 Merge branch 'master' into 15-remove-sudo-from-makefile 2018-12-20 21:06:21 +01:00
Mikolaj Pawlikowski
23a8216e6d Merge branch 'master' into screenshot 2018-12-20 21:05:59 +01:00
Mikolaj Pawlikowski
7eec26b194 Add a large size screenshot
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 18:52:44 +01:00
Mikolaj Pawlikowski
97808d9365 Update README.md
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 18:51:11 +01:00
Ivan Kalita
d780fcaa4a Remove sudo from docker-related Makefile targets
According to #15.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-20 18:30:45 +01:00
Ivan Kalita
d40bed4d3e Fix of the healthz endpoint handler
According to #8.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-20 18:17:09 +01:00
Ivan Kalita
ebbe41f4ef Add simple healthz endpoint
According to #8.

Signed-off-by: Ivan Kalita <kaduev13@gmail.com>
2018-12-20 18:12:18 +01:00
50 changed files with 837 additions and 466 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.git/
/vendor/

View File

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

View File

@@ -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
View File

@@ -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",

View File

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

View File

@@ -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.
![](./extras/screenshot.png)
![](./extras/screenshot-big.png)
You can click on various nodes to gray out the clutter and see more information.

View File

@@ -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`'" \

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 KiB

View File

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

View File

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

View File

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

View File

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

View File

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

View 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
}

View 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
}

View File

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

View File

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

View File

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

View File

@@ -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)

View File

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

View File

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

View File

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

View File

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

View 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
}

View File

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

View File

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

View File

@@ -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))

View File

@@ -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.
/*

View File

@@ -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": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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)
}

View 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)
}

View 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
}

View 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
}
}
}

View 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()
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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'