*: bump Open API dependencies (#2024)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
8beee36bd0
commit
d5f6f88928
2
Makefile
2
Makefile
|
@ -42,7 +42,7 @@ SWAGGER = docker run \
|
|||
--user=$(shell id -u $(USER)):$(shell id -g $(USER)) \
|
||||
--rm \
|
||||
-v $(shell pwd):/go/src/github.com/prometheus/alertmanager \
|
||||
-w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.18.0
|
||||
-w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.20.1
|
||||
|
||||
api/v2/models api/v2/restapi api/v2/client: api/v2/openapi.yaml
|
||||
-rm -r api/v2/{client,models,restapi}
|
||||
|
|
|
@ -20,6 +20,8 @@ package alert
|
|||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
@ -62,8 +64,14 @@ func (a *Client) GetAlerts(params *GetAlertsParams) (*GetAlertsOK, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetAlertsOK), nil
|
||||
|
||||
success, ok := result.(*GetAlertsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -90,8 +98,14 @@ func (a *Client) PostAlerts(params *PostAlertsParams) (*PostAlertsOK, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*PostAlertsOK), nil
|
||||
|
||||
success, ok := result.(*PostAlertsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for postAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
|
|
|
@ -38,21 +38,18 @@ type GetAlertsReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetAlertsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetAlertsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 400:
|
||||
result := NewGetAlertsBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
case 500:
|
||||
result := NewGetAlertsInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -82,6 +79,10 @@ func (o *GetAlertsOK) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts][%d] getAlertsOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertsOK) GetPayload() models.GettableAlerts {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -109,6 +110,10 @@ func (o *GetAlertsBadRequest) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts][%d] getAlertsBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertsBadRequest) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -136,6 +141,10 @@ func (o *GetAlertsInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts][%d] getAlertsInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertsInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -36,21 +36,18 @@ type PostAlertsReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *PostAlertsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewPostAlertsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 400:
|
||||
result := NewPostAlertsBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
case 500:
|
||||
result := NewPostAlertsInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -101,6 +98,10 @@ func (o *PostAlertsBadRequest) Error() string {
|
|||
return fmt.Sprintf("[POST /alerts][%d] postAlertsBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
|
||||
func (o *PostAlertsBadRequest) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PostAlertsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -128,6 +129,10 @@ func (o *PostAlertsInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[POST /alerts][%d] postAlertsInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *PostAlertsInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PostAlertsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -20,6 +20,8 @@ package alertgroup
|
|||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
@ -62,8 +64,14 @@ func (a *Client) GetAlertGroups(params *GetAlertGroupsParams) (*GetAlertGroupsOK
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetAlertGroupsOK), nil
|
||||
|
||||
success, ok := result.(*GetAlertGroupsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getAlertGroups: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
|
|
|
@ -38,21 +38,18 @@ type GetAlertGroupsReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetAlertGroupsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetAlertGroupsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 400:
|
||||
result := NewGetAlertGroupsBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
case 500:
|
||||
result := NewGetAlertGroupsInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -82,6 +79,10 @@ func (o *GetAlertGroupsOK) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts/groups][%d] getAlertGroupsOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsOK) GetPayload() models.AlertGroups {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -109,6 +110,10 @@ func (o *GetAlertGroupsBadRequest) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts/groups][%d] getAlertGroupsBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsBadRequest) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -136,6 +141,10 @@ func (o *GetAlertGroupsInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[GET /alerts/groups][%d] getAlertGroupsInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetAlertGroupsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -20,6 +20,8 @@ package general
|
|||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
@ -62,8 +64,14 @@ func (a *Client) GetStatus(params *GetStatusParams) (*GetStatusOK, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetStatusOK), nil
|
||||
|
||||
success, ok := result.(*GetStatusOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getStatus: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
|
|
|
@ -38,7 +38,6 @@ type GetStatusReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetStatusReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetStatusOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -68,6 +67,10 @@ func (o *GetStatusOK) Error() string {
|
|||
return fmt.Sprintf("[GET /status][%d] getStatusOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetStatusOK) GetPayload() *models.AlertmanagerStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetStatusOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.AlertmanagerStatus)
|
||||
|
|
|
@ -38,7 +38,6 @@ type GetReceiversReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetReceiversReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetReceiversOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -68,6 +67,10 @@ func (o *GetReceiversOK) Error() string {
|
|||
return fmt.Sprintf("[GET /receivers][%d] getReceiversOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetReceiversOK) GetPayload() []*models.Receiver {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetReceiversOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -20,6 +20,8 @@ package receiver
|
|||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
@ -62,8 +64,14 @@ func (a *Client) GetReceivers(params *GetReceiversParams) (*GetReceiversOK, erro
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetReceiversOK), nil
|
||||
|
||||
success, ok := result.(*GetReceiversOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getReceivers: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
|
|
|
@ -36,14 +36,12 @@ type DeleteSilenceReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteSilenceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewDeleteSilenceOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 500:
|
||||
result := NewDeleteSilenceInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -94,6 +92,10 @@ func (o *DeleteSilenceInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[DELETE /silence/{silenceID}][%d] deleteSilenceInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *DeleteSilenceInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteSilenceInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -38,21 +38,18 @@ type GetSilenceReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetSilenceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetSilenceOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 404:
|
||||
result := NewGetSilenceNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
case 500:
|
||||
result := NewGetSilenceInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -82,6 +79,10 @@ func (o *GetSilenceOK) Error() string {
|
|||
return fmt.Sprintf("[GET /silence/{silenceID}][%d] getSilenceOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetSilenceOK) GetPayload() *models.GettableSilence {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetSilenceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.GettableSilence)
|
||||
|
@ -132,6 +133,10 @@ func (o *GetSilenceInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[GET /silence/{silenceID}][%d] getSilenceInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetSilenceInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetSilenceInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -38,14 +38,12 @@ type GetSilencesReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetSilencesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewGetSilencesOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 500:
|
||||
result := NewGetSilencesInternalServerError()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -75,6 +73,10 @@ func (o *GetSilencesOK) Error() string {
|
|||
return fmt.Sprintf("[GET /silences][%d] getSilencesOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetSilencesOK) GetPayload() models.GettableSilences {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetSilencesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -102,6 +104,10 @@ func (o *GetSilencesInternalServerError) Error() string {
|
|||
return fmt.Sprintf("[GET /silences][%d] getSilencesInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetSilencesInternalServerError) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetSilencesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -37,21 +37,18 @@ type PostSilencesReader struct {
|
|||
// ReadResponse reads a server response into the received o.
|
||||
func (o *PostSilencesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewPostSilencesOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
case 400:
|
||||
result := NewPostSilencesBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
case 404:
|
||||
result := NewPostSilencesNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
|
@ -81,6 +78,10 @@ func (o *PostSilencesOK) Error() string {
|
|||
return fmt.Sprintf("[POST /silences][%d] postSilencesOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *PostSilencesOK) GetPayload() *PostSilencesOKBody {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PostSilencesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(PostSilencesOKBody)
|
||||
|
@ -110,6 +111,10 @@ func (o *PostSilencesBadRequest) Error() string {
|
|||
return fmt.Sprintf("[POST /silences][%d] postSilencesBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
|
||||
func (o *PostSilencesBadRequest) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PostSilencesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
@ -137,6 +142,10 @@ func (o *PostSilencesNotFound) Error() string {
|
|||
return fmt.Sprintf("[POST /silences][%d] postSilencesNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
|
||||
func (o *PostSilencesNotFound) GetPayload() string {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PostSilencesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
|
|
|
@ -20,6 +20,8 @@ package silence
|
|||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
@ -62,8 +64,14 @@ func (a *Client) DeleteSilence(params *DeleteSilenceParams) (*DeleteSilenceOK, e
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*DeleteSilenceOK), nil
|
||||
|
||||
success, ok := result.(*DeleteSilenceOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for deleteSilence: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -90,8 +98,14 @@ func (a *Client) GetSilence(params *GetSilenceParams) (*GetSilenceOK, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetSilenceOK), nil
|
||||
|
||||
success, ok := result.(*GetSilenceOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getSilence: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -118,8 +132,14 @@ func (a *Client) GetSilences(params *GetSilencesParams) (*GetSilencesOK, error)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*GetSilencesOK), nil
|
||||
|
||||
success, ok := result.(*GetSilencesOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getSilences: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -146,8 +166,14 @@ func (a *Client) PostSilences(params *PostSilencesParams) (*PostSilencesOK, erro
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*PostSilencesOK), nil
|
||||
|
||||
success, ok := result.(*PostSilencesOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for postSilences: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
|
|
|
@ -52,33 +52,51 @@ func configureAPI(api *operations.AlertmanagerAPI) http.Handler {
|
|||
|
||||
api.JSONProducer = runtime.JSONProducer()
|
||||
|
||||
api.SilenceDeleteSilenceHandler = silence.DeleteSilenceHandlerFunc(func(params silence.DeleteSilenceParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.DeleteSilence has not yet been implemented")
|
||||
})
|
||||
api.AlertgroupGetAlertGroupsHandler = alertgroup.GetAlertGroupsHandlerFunc(func(params alertgroup.GetAlertGroupsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alertgroup.GetAlertGroups has not yet been implemented")
|
||||
})
|
||||
api.AlertGetAlertsHandler = alert.GetAlertsHandlerFunc(func(params alert.GetAlertsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alert.GetAlerts has not yet been implemented")
|
||||
})
|
||||
api.ReceiverGetReceiversHandler = receiver.GetReceiversHandlerFunc(func(params receiver.GetReceiversParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation receiver.GetReceivers has not yet been implemented")
|
||||
})
|
||||
api.SilenceGetSilenceHandler = silence.GetSilenceHandlerFunc(func(params silence.GetSilenceParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.GetSilence has not yet been implemented")
|
||||
})
|
||||
api.SilenceGetSilencesHandler = silence.GetSilencesHandlerFunc(func(params silence.GetSilencesParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.GetSilences has not yet been implemented")
|
||||
})
|
||||
api.GeneralGetStatusHandler = general.GetStatusHandlerFunc(func(params general.GetStatusParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation general.GetStatus has not yet been implemented")
|
||||
})
|
||||
api.AlertPostAlertsHandler = alert.PostAlertsHandlerFunc(func(params alert.PostAlertsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alert.PostAlerts has not yet been implemented")
|
||||
})
|
||||
api.SilencePostSilencesHandler = silence.PostSilencesHandlerFunc(func(params silence.PostSilencesParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.PostSilences has not yet been implemented")
|
||||
})
|
||||
if api.SilenceDeleteSilenceHandler == nil {
|
||||
api.SilenceDeleteSilenceHandler = silence.DeleteSilenceHandlerFunc(func(params silence.DeleteSilenceParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.DeleteSilence has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.AlertgroupGetAlertGroupsHandler == nil {
|
||||
api.AlertgroupGetAlertGroupsHandler = alertgroup.GetAlertGroupsHandlerFunc(func(params alertgroup.GetAlertGroupsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alertgroup.GetAlertGroups has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.AlertGetAlertsHandler == nil {
|
||||
api.AlertGetAlertsHandler = alert.GetAlertsHandlerFunc(func(params alert.GetAlertsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alert.GetAlerts has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.ReceiverGetReceiversHandler == nil {
|
||||
api.ReceiverGetReceiversHandler = receiver.GetReceiversHandlerFunc(func(params receiver.GetReceiversParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation receiver.GetReceivers has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.SilenceGetSilenceHandler == nil {
|
||||
api.SilenceGetSilenceHandler = silence.GetSilenceHandlerFunc(func(params silence.GetSilenceParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.GetSilence has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.SilenceGetSilencesHandler == nil {
|
||||
api.SilenceGetSilencesHandler = silence.GetSilencesHandlerFunc(func(params silence.GetSilencesParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.GetSilences has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.GeneralGetStatusHandler == nil {
|
||||
api.GeneralGetStatusHandler = general.GetStatusHandlerFunc(func(params general.GetStatusParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation general.GetStatus has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.AlertPostAlertsHandler == nil {
|
||||
api.AlertPostAlertsHandler = alert.PostAlertsHandlerFunc(func(params alert.PostAlertsParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation alert.PostAlerts has not yet been implemented")
|
||||
})
|
||||
}
|
||||
if api.SilencePostSilencesHandler == nil {
|
||||
api.SilencePostSilencesHandler = silence.PostSilencesHandlerFunc(func(params silence.PostSilencesParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation silence.PostSilences has not yet been implemented")
|
||||
})
|
||||
}
|
||||
|
||||
api.ServerShutdown = func() {}
|
||||
|
||||
|
|
|
@ -65,13 +65,13 @@ func (o *GetAlertsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pro
|
|||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if payload == nil {
|
||||
payload = make(models.GettableAlerts, 0, 50)
|
||||
// return empty array
|
||||
payload = models.GettableAlerts{}
|
||||
}
|
||||
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetAlertsBadRequestCode is the HTTP code returned for type GetAlertsBadRequest
|
||||
|
@ -114,7 +114,6 @@ func (o *GetAlertsBadRequest) WriteResponse(rw http.ResponseWriter, producer run
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetAlertsInternalServerErrorCode is the HTTP code returned for type GetAlertsInternalServerError
|
||||
|
@ -157,5 +156,4 @@ func (o *GetAlertsInternalServerError) WriteResponse(rw http.ResponseWriter, pro
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ func (o *GetAlertsURL) Build() (*url.URL, error) {
|
|||
|
||||
qs := make(url.Values)
|
||||
|
||||
var active string
|
||||
var activeQ string
|
||||
if o.Active != nil {
|
||||
active = swag.FormatBool(*o.Active)
|
||||
activeQ = swag.FormatBool(*o.Active)
|
||||
}
|
||||
if active != "" {
|
||||
qs.Set("active", active)
|
||||
if activeQ != "" {
|
||||
qs.Set("active", activeQ)
|
||||
}
|
||||
|
||||
var filterIR []string
|
||||
|
@ -89,36 +89,36 @@ func (o *GetAlertsURL) Build() (*url.URL, error) {
|
|||
qs.Add("filter", qsv)
|
||||
}
|
||||
|
||||
var inhibited string
|
||||
var inhibitedQ string
|
||||
if o.Inhibited != nil {
|
||||
inhibited = swag.FormatBool(*o.Inhibited)
|
||||
inhibitedQ = swag.FormatBool(*o.Inhibited)
|
||||
}
|
||||
if inhibited != "" {
|
||||
qs.Set("inhibited", inhibited)
|
||||
if inhibitedQ != "" {
|
||||
qs.Set("inhibited", inhibitedQ)
|
||||
}
|
||||
|
||||
var receiver string
|
||||
var receiverQ string
|
||||
if o.Receiver != nil {
|
||||
receiver = *o.Receiver
|
||||
receiverQ = *o.Receiver
|
||||
}
|
||||
if receiver != "" {
|
||||
qs.Set("receiver", receiver)
|
||||
if receiverQ != "" {
|
||||
qs.Set("receiver", receiverQ)
|
||||
}
|
||||
|
||||
var silenced string
|
||||
var silencedQ string
|
||||
if o.Silenced != nil {
|
||||
silenced = swag.FormatBool(*o.Silenced)
|
||||
silencedQ = swag.FormatBool(*o.Silenced)
|
||||
}
|
||||
if silenced != "" {
|
||||
qs.Set("silenced", silenced)
|
||||
if silencedQ != "" {
|
||||
qs.Set("silenced", silencedQ)
|
||||
}
|
||||
|
||||
var unprocessed string
|
||||
var unprocessedQ string
|
||||
if o.Unprocessed != nil {
|
||||
unprocessed = swag.FormatBool(*o.Unprocessed)
|
||||
unprocessedQ = swag.FormatBool(*o.Unprocessed)
|
||||
}
|
||||
if unprocessed != "" {
|
||||
qs.Set("unprocessed", unprocessed)
|
||||
if unprocessedQ != "" {
|
||||
qs.Set("unprocessed", unprocessedQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
|
|
@ -89,7 +89,6 @@ func (o *PostAlertsBadRequest) WriteResponse(rw http.ResponseWriter, producer ru
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// PostAlertsInternalServerErrorCode is the HTTP code returned for type PostAlertsInternalServerError
|
||||
|
@ -132,5 +131,4 @@ func (o *PostAlertsInternalServerError) WriteResponse(rw http.ResponseWriter, pr
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,13 +65,13 @@ func (o *GetAlertGroupsOK) WriteResponse(rw http.ResponseWriter, producer runtim
|
|||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if payload == nil {
|
||||
payload = make(models.AlertGroups, 0, 50)
|
||||
// return empty array
|
||||
payload = models.AlertGroups{}
|
||||
}
|
||||
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetAlertGroupsBadRequestCode is the HTTP code returned for type GetAlertGroupsBadRequest
|
||||
|
@ -114,7 +114,6 @@ func (o *GetAlertGroupsBadRequest) WriteResponse(rw http.ResponseWriter, produce
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetAlertGroupsInternalServerErrorCode is the HTTP code returned for type GetAlertGroupsInternalServerError
|
||||
|
@ -157,5 +156,4 @@ func (o *GetAlertGroupsInternalServerError) WriteResponse(rw http.ResponseWriter
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,12 +66,12 @@ func (o *GetAlertGroupsURL) Build() (*url.URL, error) {
|
|||
|
||||
qs := make(url.Values)
|
||||
|
||||
var active string
|
||||
var activeQ string
|
||||
if o.Active != nil {
|
||||
active = swag.FormatBool(*o.Active)
|
||||
activeQ = swag.FormatBool(*o.Active)
|
||||
}
|
||||
if active != "" {
|
||||
qs.Set("active", active)
|
||||
if activeQ != "" {
|
||||
qs.Set("active", activeQ)
|
||||
}
|
||||
|
||||
var filterIR []string
|
||||
|
@ -88,28 +88,28 @@ func (o *GetAlertGroupsURL) Build() (*url.URL, error) {
|
|||
qs.Add("filter", qsv)
|
||||
}
|
||||
|
||||
var inhibited string
|
||||
var inhibitedQ string
|
||||
if o.Inhibited != nil {
|
||||
inhibited = swag.FormatBool(*o.Inhibited)
|
||||
inhibitedQ = swag.FormatBool(*o.Inhibited)
|
||||
}
|
||||
if inhibited != "" {
|
||||
qs.Set("inhibited", inhibited)
|
||||
if inhibitedQ != "" {
|
||||
qs.Set("inhibited", inhibitedQ)
|
||||
}
|
||||
|
||||
var receiver string
|
||||
var receiverQ string
|
||||
if o.Receiver != nil {
|
||||
receiver = *o.Receiver
|
||||
receiverQ = *o.Receiver
|
||||
}
|
||||
if receiver != "" {
|
||||
qs.Set("receiver", receiver)
|
||||
if receiverQ != "" {
|
||||
qs.Set("receiver", receiverQ)
|
||||
}
|
||||
|
||||
var silenced string
|
||||
var silencedQ string
|
||||
if o.Silenced != nil {
|
||||
silenced = swag.FormatBool(*o.Silenced)
|
||||
silencedQ = swag.FormatBool(*o.Silenced)
|
||||
}
|
||||
if silenced != "" {
|
||||
qs.Set("silenced", silenced)
|
||||
if silencedQ != "" {
|
||||
qs.Set("silenced", silencedQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
|
|
@ -100,13 +100,13 @@ type AlertmanagerAPI struct {
|
|||
Middleware func(middleware.Builder) http.Handler
|
||||
|
||||
// BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
|
||||
// It has a default implemention in the security package, however you can replace it for your particular usage.
|
||||
// It has a default implementation in the security package, however you can replace it for your particular usage.
|
||||
BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
|
||||
// APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
|
||||
// It has a default implemention in the security package, however you can replace it for your particular usage.
|
||||
// It has a default implementation in the security package, however you can replace it for your particular usage.
|
||||
APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
|
||||
// BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
|
||||
// It has a default implemention in the security package, however you can replace it for your particular usage.
|
||||
// It has a default implementation in the security package, however you can replace it for your particular usage.
|
||||
BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
|
||||
|
||||
// JSONConsumer registers a consumer for a "application/json" mime type
|
||||
|
|
|
@ -65,11 +65,11 @@ func (o *GetReceiversOK) WriteResponse(rw http.ResponseWriter, producer runtime.
|
|||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if payload == nil {
|
||||
// return empty array
|
||||
payload = make([]*models.Receiver, 0, 50)
|
||||
}
|
||||
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,5 +89,4 @@ func (o *DeleteSilenceInternalServerError) WriteResponse(rw http.ResponseWriter,
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ func (o *DeleteSilenceURL) Build() (*url.URL, error) {
|
|||
if silenceID != "" {
|
||||
_path = strings.Replace(_path, "{silenceID}", silenceID, -1)
|
||||
} else {
|
||||
return nil, errors.New("SilenceID is required on DeleteSilenceURL")
|
||||
return nil, errors.New("silenceId is required on DeleteSilenceURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
|
|
|
@ -135,5 +135,4 @@ func (o *GetSilenceInternalServerError) WriteResponse(rw http.ResponseWriter, pr
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ func (o *GetSilenceURL) Build() (*url.URL, error) {
|
|||
if silenceID != "" {
|
||||
_path = strings.Replace(_path, "{silenceID}", silenceID, -1)
|
||||
} else {
|
||||
return nil, errors.New("SilenceID is required on GetSilenceURL")
|
||||
return nil, errors.New("silenceId is required on GetSilenceURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
|
|
|
@ -65,13 +65,13 @@ func (o *GetSilencesOK) WriteResponse(rw http.ResponseWriter, producer runtime.P
|
|||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if payload == nil {
|
||||
payload = make(models.GettableSilences, 0, 50)
|
||||
// return empty array
|
||||
payload = models.GettableSilences{}
|
||||
}
|
||||
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetSilencesInternalServerErrorCode is the HTTP code returned for type GetSilencesInternalServerError
|
||||
|
@ -114,5 +114,4 @@ func (o *GetSilencesInternalServerError) WriteResponse(rw http.ResponseWriter, p
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,7 +109,6 @@ func (o *PostSilencesBadRequest) WriteResponse(rw http.ResponseWriter, producer
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// PostSilencesNotFoundCode is the HTTP code returned for type PostSilencesNotFound
|
||||
|
@ -152,5 +151,4 @@ func (o *PostSilencesNotFound) WriteResponse(rw http.ResponseWriter, producer ru
|
|||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ type Server struct {
|
|||
TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"`
|
||||
TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"`
|
||||
TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"`
|
||||
TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure conections" env:"TLS_PRIVATE_KEY"`
|
||||
TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"`
|
||||
TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"`
|
||||
TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"`
|
||||
TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"`
|
||||
|
@ -147,7 +147,6 @@ func (s *Server) SetAPI(api *operations.AlertmanagerAPI) {
|
|||
}
|
||||
|
||||
s.api = api
|
||||
s.api.Logger = log.Printf
|
||||
s.handler = configureAPI(api)
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,7 @@ func (s *Server) Serve() (err error) {
|
|||
// https://github.com/golang/go/tree/master/src/crypto/elliptic
|
||||
CurvePreferences: []tls.CurveID{tls.CurveP256},
|
||||
// Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility
|
||||
NextProtos: []string{"http/1.1", "h2"},
|
||||
NextProtos: []string{"h2", "http/1.1"},
|
||||
// https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols
|
||||
MinVersion: tls.VersionTLS12,
|
||||
// These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy
|
||||
|
@ -307,7 +306,7 @@ func (s *Server) Serve() (err error) {
|
|||
// call custom TLS configurator
|
||||
configureTLS(httpsServer.TLSConfig)
|
||||
|
||||
if len(httpsServer.TLSConfig.Certificates) == 0 {
|
||||
if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil {
|
||||
// after standard and custom config are passed, this ends up with no certificate
|
||||
if s.TLSCertificate == "" {
|
||||
if s.TLSCertificateKey == "" {
|
||||
|
|
6
go.mod
6
go.mod
|
@ -6,15 +6,15 @@ require (
|
|||
github.com/go-kit/kit v0.9.0
|
||||
github.com/go-openapi/errors v0.19.2
|
||||
github.com/go-openapi/loads v0.19.2
|
||||
github.com/go-openapi/runtime v0.19.3
|
||||
github.com/go-openapi/runtime v0.19.4
|
||||
github.com/go-openapi/spec v0.19.2
|
||||
github.com/go-openapi/strfmt v0.19.2
|
||||
github.com/go-openapi/swag v0.19.4
|
||||
github.com/go-openapi/swag v0.19.5
|
||||
github.com/go-openapi/validate v0.19.2
|
||||
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
|
||||
github.com/hashicorp/go-sockaddr v1.0.2
|
||||
github.com/hashicorp/memberlist v0.1.4
|
||||
github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1
|
||||
github.com/oklog/run v1.0.0
|
||||
|
|
6
go.sum
6
go.sum
|
@ -132,6 +132,8 @@ github.com/go-openapi/runtime v0.18.0/go.mod h1:uI6pHuxWYTy94zZxgcwJkUWa9wbIlhte
|
|||
github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64=
|
||||
github.com/go-openapi/runtime v0.19.3 h1:pyVE0l7ybsThmn9Y9kWRK3o/cUmaT8WVfd6pDCIKeNE=
|
||||
github.com/go-openapi/runtime v0.19.3/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4=
|
||||
github.com/go-openapi/runtime v0.19.4 h1:csnOgcgAiuGoM/Po7PEpKDoNulCcF3FGbSnbHfxgjMI=
|
||||
github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4=
|
||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||
github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.17.2 h1:eb2NbuCnoe8cWAxhtK6CfMWUYmiFEZJ9Hx3Z2WRwJ5M=
|
||||
|
@ -154,6 +156,8 @@ github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/
|
|||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.4 h1:i/65mCM9s1h8eCkT07F5Z/C1e/f8VTgEwer+00yevpA=
|
||||
github.com/go-openapi/swag v0.19.4/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/validate v0.17.2 h1:lwFfiS4sv5DvOrsYDsYq4N7UU8ghXiYtPJ+VcQnC3Xg=
|
||||
github.com/go-openapi/validate v0.17.2/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
|
||||
github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
|
||||
|
@ -261,6 +265,8 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
|
|||
github.com/influxdata/influxdb v1.7.7/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
|
||||
github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc h1:0L2sGkaj6MWuV1BfXsrLJ/+XA8RzKKVsYlLVXNkK1Lw=
|
||||
github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 h1:K//n/AqR5HjG3qxbrBCL4vJPW0MVFSs9CPK1OOJdRME=
|
||||
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package runtime
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -42,7 +43,68 @@ func AllowsBody(r *http.Request) bool {
|
|||
|
||||
// HasBody returns true if this method needs a content-type
|
||||
func HasBody(r *http.Request) bool {
|
||||
return len(r.TransferEncoding) > 0 || r.ContentLength > 0
|
||||
// happy case: we have a content length set
|
||||
if r.ContentLength > 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
if r.Header.Get(http.CanonicalHeaderKey("content-length")) != "" {
|
||||
// in this case, no Transfer-Encoding should be present
|
||||
// we have a header set but it was explicitly set to 0, so we assume no body
|
||||
return false
|
||||
}
|
||||
|
||||
rdr := newPeekingReader(r.Body)
|
||||
r.Body = rdr
|
||||
return rdr.HasContent()
|
||||
}
|
||||
|
||||
func newPeekingReader(r io.ReadCloser) *peekingReader {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return &peekingReader{
|
||||
underlying: bufio.NewReader(r),
|
||||
orig: r,
|
||||
}
|
||||
}
|
||||
|
||||
type peekingReader struct {
|
||||
underlying interface {
|
||||
Buffered() int
|
||||
Peek(int) ([]byte, error)
|
||||
Read([]byte) (int, error)
|
||||
}
|
||||
orig io.ReadCloser
|
||||
}
|
||||
|
||||
func (p *peekingReader) HasContent() bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
if p.underlying.Buffered() > 0 {
|
||||
return true
|
||||
}
|
||||
b, err := p.underlying.Peek(1)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return len(b) > 0
|
||||
}
|
||||
|
||||
func (p *peekingReader) Read(d []byte) (int, error) {
|
||||
if p == nil {
|
||||
return 0, io.EOF
|
||||
}
|
||||
return p.underlying.Read(d)
|
||||
}
|
||||
|
||||
func (p *peekingReader) Close() error {
|
||||
p.underlying = nil
|
||||
if p.orig != nil {
|
||||
return p.orig.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// JSONRequest creates a new http request with json headers set
|
||||
|
|
|
@ -75,6 +75,7 @@ type secCtxKey uint8
|
|||
|
||||
const (
|
||||
failedBasicAuth secCtxKey = iota
|
||||
oauth2SchemeName
|
||||
)
|
||||
|
||||
func FailedBasicAuth(r *http.Request) string {
|
||||
|
@ -89,6 +90,18 @@ func FailedBasicAuthCtx(ctx context.Context) string {
|
|||
return v
|
||||
}
|
||||
|
||||
func OAuth2SchemeName(r *http.Request) string {
|
||||
return OAuth2SchemeNameCtx(r.Context())
|
||||
}
|
||||
|
||||
func OAuth2SchemeNameCtx(ctx context.Context) string {
|
||||
v, ok := ctx.Value(oauth2SchemeName).(string)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// BasicAuth creates a basic auth authenticator with the provided authentication function
|
||||
func BasicAuth(authenticate UserPassAuthentication) runtime.Authenticator {
|
||||
return BasicAuthRealm(DefaultRealmName, authenticate)
|
||||
|
@ -224,6 +237,8 @@ func BearerAuth(name string, authenticate ScopedTokenAuthentication) runtime.Aut
|
|||
return false, nil, nil
|
||||
}
|
||||
|
||||
rctx := context.WithValue(r.Request.Context(), oauth2SchemeName, name)
|
||||
*r.Request = *r.Request.WithContext(rctx)
|
||||
p, err := authenticate(token, r.RequiredScopes)
|
||||
return true, p, err
|
||||
})
|
||||
|
@ -252,7 +267,8 @@ func BearerAuthCtx(name string, authenticate ScopedTokenAuthenticationCtx) runti
|
|||
return false, nil, nil
|
||||
}
|
||||
|
||||
ctx, p, err := authenticate(r.Request.Context(), token, r.RequiredScopes)
|
||||
rctx := context.WithValue(r.Request.Context(), oauth2SchemeName, name)
|
||||
ctx, p, err := authenticate(rctx, token, r.RequiredScopes)
|
||||
*r.Request = *r.Request.WithContext(ctx)
|
||||
return true, p, err
|
||||
})
|
||||
|
|
|
@ -143,19 +143,43 @@ func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
|||
}
|
||||
|
||||
func transformData(input interface{}) (out interface{}, err error) {
|
||||
format := func(t interface{}) (string, error) {
|
||||
switch k := t.(type) {
|
||||
case string:
|
||||
return k, nil
|
||||
case uint:
|
||||
return strconv.FormatUint(uint64(k), 10), nil
|
||||
case uint8:
|
||||
return strconv.FormatUint(uint64(k), 10), nil
|
||||
case uint16:
|
||||
return strconv.FormatUint(uint64(k), 10), nil
|
||||
case uint32:
|
||||
return strconv.FormatUint(uint64(k), 10), nil
|
||||
case uint64:
|
||||
return strconv.FormatUint(k, 10), nil
|
||||
case int:
|
||||
return strconv.Itoa(k), nil
|
||||
case int8:
|
||||
return strconv.FormatInt(int64(k), 10), nil
|
||||
case int16:
|
||||
return strconv.FormatInt(int64(k), 10), nil
|
||||
case int32:
|
||||
return strconv.FormatInt(int64(k), 10), nil
|
||||
case int64:
|
||||
return strconv.FormatInt(k, 10), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unexpected map key type, got: %T", k)
|
||||
}
|
||||
}
|
||||
|
||||
switch in := input.(type) {
|
||||
case yaml.MapSlice:
|
||||
|
||||
o := make(JSONMapSlice, len(in))
|
||||
for i, mi := range in {
|
||||
var nmi JSONMapItem
|
||||
switch k := mi.Key.(type) {
|
||||
case string:
|
||||
nmi.Key = k
|
||||
case int:
|
||||
nmi.Key = strconv.Itoa(k)
|
||||
default:
|
||||
return nil, fmt.Errorf("types don't match expect map key string or int got: %T", mi.Key)
|
||||
if nmi.Key, err = format(mi.Key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, ert := transformData(mi.Value)
|
||||
|
@ -170,13 +194,8 @@ func transformData(input interface{}) (out interface{}, err error) {
|
|||
o := make(JSONMapSlice, 0, len(in))
|
||||
for ke, va := range in {
|
||||
var nmi JSONMapItem
|
||||
switch k := ke.(type) {
|
||||
case string:
|
||||
nmi.Key = k
|
||||
case int:
|
||||
nmi.Key = strconv.Itoa(k)
|
||||
default:
|
||||
return nil, fmt.Errorf("types don't match expect map key string or int got: %T", ke)
|
||||
if nmi.Key, err = format(ke); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, ert := transformData(va)
|
||||
|
|
|
@ -125,10 +125,6 @@ The following is a list of tags for struct fields supported by go-flags:
|
|||
gets prepended to every option's long name and
|
||||
subgroup's namespace of this group, separated by
|
||||
the parser's namespace delimiter (optional)
|
||||
env-namespace: when specified on a group struct field, the env-namespace
|
||||
gets prepended to every option's env key and
|
||||
subgroup's env-namespace of this group, separated by
|
||||
the parser's env-namespace delimiter (optional)
|
||||
command: when specified on a struct field, makes the struct
|
||||
field a (sub)command with the given name (optional)
|
||||
subcommands-optional: when specified on a command struct field, makes
|
||||
|
|
|
@ -34,9 +34,6 @@ type Group struct {
|
|||
// The namespace of the group
|
||||
Namespace string
|
||||
|
||||
// The environment namespace of the group
|
||||
EnvNamespace string
|
||||
|
||||
// If true, the group is not displayed in the help or man page
|
||||
Hidden bool
|
||||
|
||||
|
@ -361,7 +358,6 @@ func (g *Group) scanSubGroupHandler(realval reflect.Value, sfield *reflect.Struc
|
|||
}
|
||||
|
||||
group.Namespace = mtag.Get("namespace")
|
||||
group.EnvNamespace = mtag.Get("env-namespace")
|
||||
group.Hidden = mtag.Get("hidden") != ""
|
||||
|
||||
return true, nil
|
||||
|
|
|
@ -225,12 +225,12 @@ func (p *Parser) writeHelpOption(writer *bufio.Writer, option *Option, info alig
|
|||
}
|
||||
|
||||
var envDef string
|
||||
if option.EnvKeyWithNamespace() != "" {
|
||||
if option.EnvDefaultKey != "" {
|
||||
var envPrintable string
|
||||
if runtime.GOOS == "windows" {
|
||||
envPrintable = "%" + option.EnvKeyWithNamespace() + "%"
|
||||
envPrintable = "%" + option.EnvDefaultKey + "%"
|
||||
} else {
|
||||
envPrintable = "$" + option.EnvKeyWithNamespace()
|
||||
envPrintable = "$" + option.EnvDefaultKey
|
||||
}
|
||||
envDef = fmt.Sprintf(" [%s]", envPrintable)
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ func writeManPageOptions(wr io.Writer, grp *Group) {
|
|||
|
||||
if len(opt.Default) != 0 {
|
||||
fmt.Fprintf(wr, " <default: \\fI%s\\fR>", manQuote(strings.Join(quoteV(opt.Default), ", ")))
|
||||
} else if len(opt.EnvKeyWithNamespace()) != 0 {
|
||||
} else if len(opt.EnvDefaultKey) != 0 {
|
||||
if runtime.GOOS == "windows" {
|
||||
fmt.Fprintf(wr, " <default: \\fI%%%s%%\\fR>", manQuote(opt.EnvKeyWithNamespace()))
|
||||
fmt.Fprintf(wr, " <default: \\fI%%%s%%\\fR>", manQuote(opt.EnvDefaultKey))
|
||||
} else {
|
||||
fmt.Fprintf(wr, " <default: \\fI$%s\\fR>", manQuote(opt.EnvKeyWithNamespace()))
|
||||
fmt.Fprintf(wr, " <default: \\fI$%s\\fR>", manQuote(opt.EnvDefaultKey))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,57 +139,6 @@ func (option *Option) LongNameWithNamespace() string {
|
|||
return longName
|
||||
}
|
||||
|
||||
// EnvKeyWithNamespace returns the option's env key with the group namespaces
|
||||
// prepended by walking up the option's group tree. Namespaces and the env key
|
||||
// itself are separated by the parser's namespace delimiter. If the env key is
|
||||
// empty an empty string is returned.
|
||||
func (option *Option) EnvKeyWithNamespace() string {
|
||||
if len(option.EnvDefaultKey) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
// fetch the namespace delimiter from the parser which is always at the
|
||||
// end of the group hierarchy
|
||||
namespaceDelimiter := ""
|
||||
g := option.group
|
||||
|
||||
for {
|
||||
if p, ok := g.parent.(*Parser); ok {
|
||||
namespaceDelimiter = p.EnvNamespaceDelimiter
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
switch i := g.parent.(type) {
|
||||
case *Command:
|
||||
g = i.Group
|
||||
case *Group:
|
||||
g = i
|
||||
}
|
||||
}
|
||||
|
||||
// concatenate long name with namespace
|
||||
key := option.EnvDefaultKey
|
||||
g = option.group
|
||||
|
||||
for g != nil {
|
||||
if g.EnvNamespace != "" {
|
||||
key = g.EnvNamespace + namespaceDelimiter + key
|
||||
}
|
||||
|
||||
switch i := g.parent.(type) {
|
||||
case *Command:
|
||||
g = i.Group
|
||||
case *Group:
|
||||
g = i
|
||||
case *Parser:
|
||||
g = nil
|
||||
}
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
// String converts an option to a human friendly readable string describing the
|
||||
// option.
|
||||
func (option *Option) String() string {
|
||||
|
@ -311,10 +260,11 @@ func (option *Option) empty() {
|
|||
func (option *Option) clearDefault() {
|
||||
usedDefault := option.Default
|
||||
|
||||
if envKey := option.EnvKeyWithNamespace(); envKey != "" {
|
||||
if envKey := option.EnvDefaultKey; envKey != "" {
|
||||
if value, ok := os.LookupEnv(envKey); ok {
|
||||
if option.EnvDefaultDelim != "" {
|
||||
usedDefault = strings.Split(value, option.EnvDefaultDelim)
|
||||
usedDefault = strings.Split(value,
|
||||
option.EnvDefaultDelim)
|
||||
} else {
|
||||
usedDefault = []string{value}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,6 @@ type Parser struct {
|
|||
// NamespaceDelimiter separates group namespaces and option long names
|
||||
NamespaceDelimiter string
|
||||
|
||||
// EnvNamespaceDelimiter separates group env namespaces and env keys
|
||||
EnvNamespaceDelimiter string
|
||||
|
||||
// UnknownOptionsHandler is a function which gets called when the parser
|
||||
// encounters an unknown option. The function receives the unknown option
|
||||
// name, a SplitArgument which specifies its value if set with an argument
|
||||
|
@ -173,10 +170,9 @@ func NewParser(data interface{}, options Options) *Parser {
|
|||
// be added to this parser by using AddGroup and AddCommand.
|
||||
func NewNamedParser(appname string, options Options) *Parser {
|
||||
p := &Parser{
|
||||
Command: newCommand(appname, "", "", nil),
|
||||
Options: options,
|
||||
NamespaceDelimiter: ".",
|
||||
EnvNamespaceDelimiter: "_",
|
||||
Command: newCommand(appname, "", "", nil),
|
||||
Options: options,
|
||||
NamespaceDelimiter: ".",
|
||||
}
|
||||
|
||||
p.Command.parent = p
|
||||
|
|
|
@ -37,7 +37,7 @@ github.com/go-openapi/jsonpointer
|
|||
github.com/go-openapi/jsonreference
|
||||
# github.com/go-openapi/loads v0.19.2
|
||||
github.com/go-openapi/loads
|
||||
# github.com/go-openapi/runtime v0.19.3
|
||||
# github.com/go-openapi/runtime v0.19.4
|
||||
github.com/go-openapi/runtime/middleware
|
||||
github.com/go-openapi/runtime
|
||||
github.com/go-openapi/runtime/client
|
||||
|
@ -51,7 +51,7 @@ github.com/go-openapi/runtime/middleware/untyped
|
|||
github.com/go-openapi/spec
|
||||
# github.com/go-openapi/strfmt v0.19.2
|
||||
github.com/go-openapi/strfmt
|
||||
# github.com/go-openapi/swag v0.19.4
|
||||
# github.com/go-openapi/swag v0.19.5
|
||||
github.com/go-openapi/swag
|
||||
# github.com/go-openapi/validate v0.19.2
|
||||
github.com/go-openapi/validate
|
||||
|
@ -104,7 +104,7 @@ github.com/hashicorp/go-sockaddr
|
|||
github.com/hashicorp/golang-lru/simplelru
|
||||
# github.com/hashicorp/memberlist v0.1.4
|
||||
github.com/hashicorp/memberlist
|
||||
# github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc
|
||||
# github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/jessevdk/go-flags
|
||||
# github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7
|
||||
github.com/jpillora/backoff
|
||||
|
|
Loading…
Reference in New Issue