Skip to content
Snippets Groups Projects
Commit 2b9590b1 authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark
Browse files

lint-fix

parent 75658a36
No related branches found
No related tags found
3 merge requests!11Big boom integration,!10Add linting,!6Draft: Akms ckms api implementation
Pipeline #180709 failed
Showing
with 69 additions and 97 deletions
...@@ -14,12 +14,10 @@ import ( ...@@ -14,12 +14,10 @@ import (
"net/http" "net/http"
) )
// DefaultAPIRouter defines the required methods for binding the api requests to a responses for the DefaultAPI // DefaultAPIRouter defines the required methods for binding the api requests to a responses for the DefaultAPI
// The DefaultAPIRouter implementation should parse necessary information from the http request, // The DefaultAPIRouter implementation should parse necessary information from the http request,
// pass the data to a DefaultAPIServicer to perform the required actions, then write the service results to the http response. // pass the data to a DefaultAPIServicer to perform the required actions, then write the service results to the http response.
type DefaultAPIRouter interface { type DefaultAPIRouter interface {
GetKey(http.ResponseWriter, *http.Request) GetKey(http.ResponseWriter, *http.Request)
GetKeyPost(http.ResponseWriter, *http.Request) GetKeyPost(http.ResponseWriter, *http.Request)
GetKeyWithIds(http.ResponseWriter, *http.Request) GetKeyWithIds(http.ResponseWriter, *http.Request)
...@@ -27,12 +25,11 @@ type DefaultAPIRouter interface { ...@@ -27,12 +25,11 @@ type DefaultAPIRouter interface {
GetStatus(http.ResponseWriter, *http.Request) GetStatus(http.ResponseWriter, *http.Request)
} }
// DefaultAPIServicer defines the api actions for the DefaultAPI service // DefaultAPIServicer defines the api actions for the DefaultAPI service
// This interface intended to stay up to date with the openapi yaml used to generate it, // This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can be ignored with the .openapi-generator-ignore file // while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API. // and updated with the logic required for the API.
type DefaultAPIServicer interface { type DefaultAPIServicer interface {
GetKey(context.Context, interface{}, int64, int64) (ImplResponse, error) GetKey(context.Context, interface{}, int64, int64) (ImplResponse, error)
GetKeyPost(context.Context, interface{}, KeyRequest) (ImplResponse, error) GetKeyPost(context.Context, interface{}, KeyRequest) (ImplResponse, error)
GetKeyWithIds(context.Context, interface{}, string) (ImplResponse, error) GetKeyWithIds(context.Context, interface{}, string) (ImplResponse, error)
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
// DefaultAPIController binds http requests to an api service and writes the service results to the http response // DefaultAPIController binds http requests to an api service and writes the service results to the http response.
type DefaultAPIController struct { type DefaultAPIController struct {
service DefaultAPIServicer service DefaultAPIServicer
errorHandler ErrorHandler errorHandler ErrorHandler
...@@ -28,14 +28,14 @@ type DefaultAPIController struct { ...@@ -28,14 +28,14 @@ type DefaultAPIController struct {
// DefaultAPIOption for how the controller is set up. // DefaultAPIOption for how the controller is set up.
type DefaultAPIOption func(*DefaultAPIController) type DefaultAPIOption func(*DefaultAPIController)
// WithDefaultAPIErrorHandler inject ErrorHandler into controller // WithDefaultAPIErrorHandler inject ErrorHandler into controller.
func WithDefaultAPIErrorHandler(h ErrorHandler) DefaultAPIOption { func WithDefaultAPIErrorHandler(h ErrorHandler) DefaultAPIOption {
return func(c *DefaultAPIController) { return func(c *DefaultAPIController) {
c.errorHandler = h c.errorHandler = h
} }
} }
// NewDefaultAPIController creates a default api controller // NewDefaultAPIController creates a default api controller.
func NewDefaultAPIController(s DefaultAPIServicer, opts ...DefaultAPIOption) Router { func NewDefaultAPIController(s DefaultAPIServicer, opts ...DefaultAPIOption) Router {
controller := &DefaultAPIController{ controller := &DefaultAPIController{
service: s, service: s,
...@@ -49,7 +49,7 @@ func NewDefaultAPIController(s DefaultAPIServicer, opts ...DefaultAPIOption) Rou ...@@ -49,7 +49,7 @@ func NewDefaultAPIController(s DefaultAPIServicer, opts ...DefaultAPIOption) Rou
return controller return controller
} }
// Routes returns all the api routes for the DefaultAPIController // Routes returns all the api routes for the DefaultAPIController.
func (c *DefaultAPIController) Routes() Routes { func (c *DefaultAPIController) Routes() Routes {
return Routes{ return Routes{
"GetKey": Route{ "GetKey": Route{
...@@ -80,7 +80,7 @@ func (c *DefaultAPIController) Routes() Routes { ...@@ -80,7 +80,7 @@ func (c *DefaultAPIController) Routes() Routes {
} }
} }
// GetKey - TBD // GetKey - TBD.
func (c *DefaultAPIController) GetKey(w http.ResponseWriter, r *http.Request) { func (c *DefaultAPIController) GetKey(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
query := r.URL.Query() query := r.URL.Query()
...@@ -111,7 +111,7 @@ func (c *DefaultAPIController) GetKey(w http.ResponseWriter, r *http.Request) { ...@@ -111,7 +111,7 @@ func (c *DefaultAPIController) GetKey(w http.ResponseWriter, r *http.Request) {
EncodeJSONResponse(result.Body, &result.Code, w) EncodeJSONResponse(result.Body, &result.Code, w)
} }
// GetKeyPost - // GetKeyPost -.
func (c *DefaultAPIController) GetKeyPost(w http.ResponseWriter, r *http.Request) { func (c *DefaultAPIController) GetKeyPost(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
slaveSAEIDParam := params["slave_SAE_ID"] slaveSAEIDParam := params["slave_SAE_ID"]
...@@ -140,7 +140,7 @@ func (c *DefaultAPIController) GetKeyPost(w http.ResponseWriter, r *http.Request ...@@ -140,7 +140,7 @@ func (c *DefaultAPIController) GetKeyPost(w http.ResponseWriter, r *http.Request
EncodeJSONResponse(result.Body, &result.Code, w) EncodeJSONResponse(result.Body, &result.Code, w)
} }
// GetKeyWithIds - TBD // GetKeyWithIds - TBD.
func (c *DefaultAPIController) GetKeyWithIds(w http.ResponseWriter, r *http.Request) { func (c *DefaultAPIController) GetKeyWithIds(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
query := r.URL.Query() query := r.URL.Query()
...@@ -156,7 +156,7 @@ func (c *DefaultAPIController) GetKeyWithIds(w http.ResponseWriter, r *http.Requ ...@@ -156,7 +156,7 @@ func (c *DefaultAPIController) GetKeyWithIds(w http.ResponseWriter, r *http.Requ
EncodeJSONResponse(result.Body, &result.Code, w) EncodeJSONResponse(result.Body, &result.Code, w)
} }
// GetKeyWithIdsPost - TBD // GetKeyWithIdsPost - TBD.
func (c *DefaultAPIController) GetKeyWithIdsPost(w http.ResponseWriter, r *http.Request) { func (c *DefaultAPIController) GetKeyWithIdsPost(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
masterSAEIDParam := params["master_SAE_ID"] masterSAEIDParam := params["master_SAE_ID"]
...@@ -185,7 +185,7 @@ func (c *DefaultAPIController) GetKeyWithIdsPost(w http.ResponseWriter, r *http. ...@@ -185,7 +185,7 @@ func (c *DefaultAPIController) GetKeyWithIdsPost(w http.ResponseWriter, r *http.
EncodeJSONResponse(result.Body, &result.Code, w) EncodeJSONResponse(result.Body, &result.Code, w)
} }
// GetStatus - TBD // GetStatus - TBD.
func (c *DefaultAPIController) GetStatus(w http.ResponseWriter, r *http.Request) { func (c *DefaultAPIController) GetStatus(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r) params := mux.Vars(r)
slaveSAEIDParam := params["slave_SAE_ID"] slaveSAEIDParam := params["slave_SAE_ID"]
......
...@@ -11,8 +11,8 @@ package etsi14 ...@@ -11,8 +11,8 @@ package etsi14
import ( import (
"context" "context"
"net/http"
"errors" "errors"
"net/http"
) )
// DefaultAPIService is a service that implements the logic for the DefaultAPIServicer // DefaultAPIService is a service that implements the logic for the DefaultAPIServicer
...@@ -21,12 +21,12 @@ import ( ...@@ -21,12 +21,12 @@ import (
type DefaultAPIService struct { type DefaultAPIService struct {
} }
// NewDefaultAPIService creates a default api service // NewDefaultAPIService creates a default api service.
func NewDefaultAPIService() DefaultAPIServicer { func NewDefaultAPIService() DefaultAPIServicer {
return &DefaultAPIService{} return &DefaultAPIService{}
} }
// GetKey - TBD // GetKey - TBD.
func (s *DefaultAPIService) GetKey(ctx context.Context, slaveSAEID interface{}, number int64, size int64) (ImplResponse, error) { func (s *DefaultAPIService) GetKey(ctx context.Context, slaveSAEID interface{}, number int64, size int64) (ImplResponse, error) {
// TODO - update GetKey with the required logic for this service method. // TODO - update GetKey with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. // Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
...@@ -46,7 +46,7 @@ func (s *DefaultAPIService) GetKey(ctx context.Context, slaveSAEID interface{}, ...@@ -46,7 +46,7 @@ func (s *DefaultAPIService) GetKey(ctx context.Context, slaveSAEID interface{},
return Response(http.StatusNotImplemented, nil), errors.New("GetKey method not implemented") return Response(http.StatusNotImplemented, nil), errors.New("GetKey method not implemented")
} }
// GetKeyPost - // GetKeyPost -.
func (s *DefaultAPIService) GetKeyPost(ctx context.Context, slaveSAEID interface{}, keyRequest KeyRequest) (ImplResponse, error) { func (s *DefaultAPIService) GetKeyPost(ctx context.Context, slaveSAEID interface{}, keyRequest KeyRequest) (ImplResponse, error) {
// TODO - update GetKeyPost with the required logic for this service method. // TODO - update GetKeyPost with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. // Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
...@@ -66,7 +66,7 @@ func (s *DefaultAPIService) GetKeyPost(ctx context.Context, slaveSAEID interface ...@@ -66,7 +66,7 @@ func (s *DefaultAPIService) GetKeyPost(ctx context.Context, slaveSAEID interface
return Response(http.StatusNotImplemented, nil), errors.New("GetKeyPost method not implemented") return Response(http.StatusNotImplemented, nil), errors.New("GetKeyPost method not implemented")
} }
// GetKeyWithIds - TBD // GetKeyWithIds - TBD.
func (s *DefaultAPIService) GetKeyWithIds(ctx context.Context, masterSAEID interface{}, keyID string) (ImplResponse, error) { func (s *DefaultAPIService) GetKeyWithIds(ctx context.Context, masterSAEID interface{}, keyID string) (ImplResponse, error) {
// TODO - update GetKeyWithIds with the required logic for this service method. // TODO - update GetKeyWithIds with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. // Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
...@@ -86,7 +86,7 @@ func (s *DefaultAPIService) GetKeyWithIds(ctx context.Context, masterSAEID inter ...@@ -86,7 +86,7 @@ func (s *DefaultAPIService) GetKeyWithIds(ctx context.Context, masterSAEID inter
return Response(http.StatusNotImplemented, nil), errors.New("GetKeyWithIds method not implemented") return Response(http.StatusNotImplemented, nil), errors.New("GetKeyWithIds method not implemented")
} }
// GetKeyWithIdsPost - TBD // GetKeyWithIdsPost - TBD.
func (s *DefaultAPIService) GetKeyWithIdsPost(ctx context.Context, masterSAEID interface{}, keyIdsRequest KeyIdsRequest) (ImplResponse, error) { func (s *DefaultAPIService) GetKeyWithIdsPost(ctx context.Context, masterSAEID interface{}, keyIdsRequest KeyIdsRequest) (ImplResponse, error) {
// TODO - update GetKeyWithIdsPost with the required logic for this service method. // TODO - update GetKeyWithIdsPost with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. // Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
...@@ -106,7 +106,7 @@ func (s *DefaultAPIService) GetKeyWithIdsPost(ctx context.Context, masterSAEID i ...@@ -106,7 +106,7 @@ func (s *DefaultAPIService) GetKeyWithIdsPost(ctx context.Context, masterSAEID i
return Response(http.StatusNotImplemented, nil), errors.New("GetKeyWithIdsPost method not implemented") return Response(http.StatusNotImplemented, nil), errors.New("GetKeyWithIdsPost method not implemented")
} }
// GetStatus - TBD // GetStatus - TBD.
func (s *DefaultAPIService) GetStatus(ctx context.Context, slaveSAEID interface{}) (ImplResponse, error) { func (s *DefaultAPIService) GetStatus(ctx context.Context, slaveSAEID interface{}) (ImplResponse, error) {
// TODO - update GetStatus with the required logic for this service method. // TODO - update GetStatus with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. // Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
......
...@@ -16,11 +16,11 @@ import ( ...@@ -16,11 +16,11 @@ import (
) )
var ( var (
// ErrTypeAssertionError is thrown when type an interface does not match the asserted type // ErrTypeAssertionError is thrown when type an interface does not match the asserted type.
ErrTypeAssertionError = errors.New("unable to assert type") ErrTypeAssertionError = errors.New("unable to assert type")
) )
// ParsingError indicates that an error has occurred when parsing request parameters // ParsingError indicates that an error has occurred when parsing request parameters.
type ParsingError struct { type ParsingError struct {
Err error Err error
} }
...@@ -33,7 +33,7 @@ func (e *ParsingError) Error() string { ...@@ -33,7 +33,7 @@ func (e *ParsingError) Error() string {
return e.Err.Error() return e.Err.Error()
} }
// RequiredError indicates that an error has occurred when parsing request parameters // RequiredError indicates that an error has occurred when parsing request parameters.
type RequiredError struct { type RequiredError struct {
Field string Field string
} }
...@@ -43,7 +43,7 @@ func (e *RequiredError) Error() string { ...@@ -43,7 +43,7 @@ func (e *RequiredError) Error() string {
} }
// ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if // ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if
// you would like errors to be handled differently from the DefaultErrorHandler // you would like errors to be handled differently from the DefaultErrorHandler.
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse) type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
// DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing // DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing
......
...@@ -13,9 +13,9 @@ import ( ...@@ -13,9 +13,9 @@ import (
"reflect" "reflect"
) )
// Response return a ImplResponse struct filled // Response return a ImplResponse struct filled.
func Response(code int, body interface{}) ImplResponse { func Response(code int, body interface{}) ImplResponse {
return ImplResponse { return ImplResponse{
Code: code, Code: code,
Body: body, Body: body,
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
package etsi14 package etsi14
// ImplResponse defines an implementation response with error code and the associated body // ImplResponse defines an implementation response with error code and the associated body.
type ImplResponse struct { type ImplResponse struct {
Code int Code int
Body interface{} Body interface{}
......
...@@ -9,22 +9,18 @@ ...@@ -9,22 +9,18 @@
package etsi14 package etsi14
type ErrorFormat struct { type ErrorFormat struct {
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
Details []map[string]string `json:"details,omitempty"` Details []map[string]string `json:"details,omitempty"`
} }
// AssertErrorFormatRequired checks if the required fields are not zero-ed // AssertErrorFormatRequired checks if the required fields are not zero-ed.
func AssertErrorFormatRequired(obj ErrorFormat) error { func AssertErrorFormatRequired(obj ErrorFormat) error {
return nil return nil
} }
// AssertErrorFormatConstraints checks if the values respects the defined constraints // AssertErrorFormatConstraints checks if the values respects the defined constraints.
func AssertErrorFormatConstraints(obj ErrorFormat) error { func AssertErrorFormatConstraints(obj ErrorFormat) error {
return nil return nil
} }
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
package etsi14 package etsi14
type KeyContainer struct { type KeyContainer struct {
Keys []KeyContainerKeysInner `json:"Keys,omitempty"` Keys []KeyContainerKeysInner `json:"Keys,omitempty"`
} }
// AssertKeyContainerRequired checks if the required fields are not zero-ed // AssertKeyContainerRequired checks if the required fields are not zero-ed.
func AssertKeyContainerRequired(obj KeyContainer) error { func AssertKeyContainerRequired(obj KeyContainer) error {
for _, el := range obj.Keys { for _, el := range obj.Keys {
if err := AssertKeyContainerKeysInnerRequired(el); err != nil { if err := AssertKeyContainerKeysInnerRequired(el); err != nil {
...@@ -27,7 +23,7 @@ func AssertKeyContainerRequired(obj KeyContainer) error { ...@@ -27,7 +23,7 @@ func AssertKeyContainerRequired(obj KeyContainer) error {
return nil return nil
} }
// AssertKeyContainerConstraints checks if the values respects the defined constraints // AssertKeyContainerConstraints checks if the values respects the defined constraints.
func AssertKeyContainerConstraints(obj KeyContainer) error { func AssertKeyContainerConstraints(obj KeyContainer) error {
return nil return nil
} }
...@@ -9,22 +9,18 @@ ...@@ -9,22 +9,18 @@
package etsi14 package etsi14
type KeyContainerKeysInner struct { type KeyContainerKeysInner struct {
KeyID string `json:"key_ID,omitempty"` KeyID string `json:"key_ID,omitempty"`
Key string `json:"key,omitempty"` Key string `json:"key,omitempty"`
} }
// AssertKeyContainerKeysInnerRequired checks if the required fields are not zero-ed // AssertKeyContainerKeysInnerRequired checks if the required fields are not zero-ed.
func AssertKeyContainerKeysInnerRequired(obj KeyContainerKeysInner) error { func AssertKeyContainerKeysInnerRequired(obj KeyContainerKeysInner) error {
return nil return nil
} }
// AssertKeyContainerKeysInnerConstraints checks if the values respects the defined constraints // AssertKeyContainerKeysInnerConstraints checks if the values respects the defined constraints.
func AssertKeyContainerKeysInnerConstraints(obj KeyContainerKeysInner) error { func AssertKeyContainerKeysInnerConstraints(obj KeyContainerKeysInner) error {
return nil return nil
} }
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
package etsi14 package etsi14
type KeyIdsRequest struct { type KeyIdsRequest struct {
KeyIDs []KeyIdsRequestKeyIdsInner `json:"key_IDs,omitempty"` KeyIDs []KeyIdsRequestKeyIdsInner `json:"key_IDs,omitempty"`
} }
// AssertKeyIdsRequestRequired checks if the required fields are not zero-ed // AssertKeyIdsRequestRequired checks if the required fields are not zero-ed.
func AssertKeyIdsRequestRequired(obj KeyIdsRequest) error { func AssertKeyIdsRequestRequired(obj KeyIdsRequest) error {
for _, el := range obj.KeyIDs { for _, el := range obj.KeyIDs {
if err := AssertKeyIdsRequestKeyIdsInnerRequired(el); err != nil { if err := AssertKeyIdsRequestKeyIdsInnerRequired(el); err != nil {
...@@ -27,7 +23,7 @@ func AssertKeyIdsRequestRequired(obj KeyIdsRequest) error { ...@@ -27,7 +23,7 @@ func AssertKeyIdsRequestRequired(obj KeyIdsRequest) error {
return nil return nil
} }
// AssertKeyIdsRequestConstraints checks if the values respects the defined constraints // AssertKeyIdsRequestConstraints checks if the values respects the defined constraints.
func AssertKeyIdsRequestConstraints(obj KeyIdsRequest) error { func AssertKeyIdsRequestConstraints(obj KeyIdsRequest) error {
return nil return nil
} }
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
package etsi14 package etsi14
type KeyIdsRequestKeyIdsInner struct { type KeyIdsRequestKeyIdsInner struct {
KeyID string `json:"key_ID"` KeyID string `json:"key_ID"`
} }
// AssertKeyIdsRequestKeyIdsInnerRequired checks if the required fields are not zero-ed // AssertKeyIdsRequestKeyIdsInnerRequired checks if the required fields are not zero-ed.
func AssertKeyIdsRequestKeyIdsInnerRequired(obj KeyIdsRequestKeyIdsInner) error { func AssertKeyIdsRequestKeyIdsInnerRequired(obj KeyIdsRequestKeyIdsInner) error {
elements := map[string]interface{}{ elements := map[string]interface{}{
"key_ID": obj.KeyID, "key_ID": obj.KeyID,
...@@ -31,7 +27,7 @@ func AssertKeyIdsRequestKeyIdsInnerRequired(obj KeyIdsRequestKeyIdsInner) error ...@@ -31,7 +27,7 @@ func AssertKeyIdsRequestKeyIdsInnerRequired(obj KeyIdsRequestKeyIdsInner) error
return nil return nil
} }
// AssertKeyIdsRequestKeyIdsInnerConstraints checks if the values respects the defined constraints // AssertKeyIdsRequestKeyIdsInnerConstraints checks if the values respects the defined constraints.
func AssertKeyIdsRequestKeyIdsInnerConstraints(obj KeyIdsRequestKeyIdsInner) error { func AssertKeyIdsRequestKeyIdsInnerConstraints(obj KeyIdsRequestKeyIdsInner) error {
return nil return nil
} }
...@@ -9,11 +9,7 @@ ...@@ -9,11 +9,7 @@
package etsi14 package etsi14
type KeyRequest struct { type KeyRequest struct {
Number int64 `json:"number,omitempty"` Number int64 `json:"number,omitempty"`
Size int64 `json:"size,omitempty"` Size int64 `json:"size,omitempty"`
...@@ -25,12 +21,12 @@ type KeyRequest struct { ...@@ -25,12 +21,12 @@ type KeyRequest struct {
ExtensionOptional []map[string]string `json:"extension_optional,omitempty"` ExtensionOptional []map[string]string `json:"extension_optional,omitempty"`
} }
// AssertKeyRequestRequired checks if the required fields are not zero-ed // AssertKeyRequestRequired checks if the required fields are not zero-ed.
func AssertKeyRequestRequired(obj KeyRequest) error { func AssertKeyRequestRequired(obj KeyRequest) error {
return nil return nil
} }
// AssertKeyRequestConstraints checks if the values respects the defined constraints // AssertKeyRequestConstraints checks if the values respects the defined constraints.
func AssertKeyRequestConstraints(obj KeyRequest) error { func AssertKeyRequestConstraints(obj KeyRequest) error {
return nil return nil
} }
...@@ -9,11 +9,7 @@ ...@@ -9,11 +9,7 @@
package etsi14 package etsi14
type Status struct { type Status struct {
SourceKMEID string `json:"source_KME_ID,omitempty"` SourceKMEID string `json:"source_KME_ID,omitempty"`
TargetKMEID string `json:"target_KME_ID,omitempty"` TargetKMEID string `json:"target_KME_ID,omitempty"`
...@@ -37,12 +33,12 @@ type Status struct { ...@@ -37,12 +33,12 @@ type Status struct {
MaxSAEIDCount int64 `json:"max_SAE_ID_count,omitempty"` MaxSAEIDCount int64 `json:"max_SAE_ID_count,omitempty"`
} }
// AssertStatusRequired checks if the required fields are not zero-ed // AssertStatusRequired checks if the required fields are not zero-ed.
func AssertStatusRequired(obj Status) error { func AssertStatusRequired(obj Status) error {
return nil return nil
} }
// AssertStatusConstraints checks if the values respects the defined constraints // AssertStatusConstraints checks if the values respects the defined constraints.
func AssertStatusConstraints(obj Status) error { func AssertStatusConstraints(obj Status) error {
return nil return nil
} }
...@@ -12,26 +12,27 @@ package etsi14 ...@@ -12,26 +12,27 @@ package etsi14
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/gorilla/mux"
"io/ioutil" "io/ioutil"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/gorilla/mux"
) )
// A Route defines the parameters for an api endpoint // A Route defines the parameters for an api endpoint.
type Route struct { type Route struct {
Method string Method string
Pattern string Pattern string
HandlerFunc http.HandlerFunc HandlerFunc http.HandlerFunc
} }
// Routes is a map of defined api endpoints // Routes is a map of defined api endpoints.
type Routes map[string]Route type Routes map[string]Route
// Router defines the required methods for retrieving api routes // Router defines the required methods for retrieving api routes.
type Router interface { type Router interface {
Routes() Routes Routes() Routes
} }
...@@ -40,7 +41,7 @@ const errMsgRequiredMissing = "required parameter is missing" ...@@ -40,7 +41,7 @@ const errMsgRequiredMissing = "required parameter is missing"
const errMsgMinValueConstraint = "provided parameter is not respecting minimum value constraint" const errMsgMinValueConstraint = "provided parameter is not respecting minimum value constraint"
const errMsgMaxValueConstraint = "provided parameter is not respecting maximum value constraint" const errMsgMaxValueConstraint = "provided parameter is not respecting maximum value constraint"
// NewRouter creates a new router for any number of api routers // NewRouter creates a new router for any number of api routers.
func NewRouter(routers ...Router) *mux.Router { func NewRouter(routers ...Router) *mux.Router {
router := mux.NewRouter().StrictSlash(true) router := mux.NewRouter().StrictSlash(true)
for _, api := range routers { for _, api := range routers {
...@@ -60,7 +61,7 @@ func NewRouter(routers ...Router) *mux.Router { ...@@ -60,7 +61,7 @@ func NewRouter(routers ...Router) *mux.Router {
return router return router
} }
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code // EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code.
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error { func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.Header().Set("Content-Type", "application/json; charset=UTF-8")
if status != nil { if status != nil {
...@@ -76,7 +77,7 @@ func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error ...@@ -76,7 +77,7 @@ func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
return nil return nil
} }
// ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file // ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file.
func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) { func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) {
_, fileHeader, err := r.FormFile(key) _, fileHeader, err := r.FormFile(key)
if err != nil { if err != nil {
...@@ -86,7 +87,7 @@ func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) { ...@@ -86,7 +87,7 @@ func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) {
return readFileHeaderToTempFile(fileHeader) return readFileHeaderToTempFile(fileHeader)
} }
// ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files // ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files.
func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error) { func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error) {
if err := r.ParseMultipartForm(32 << 20); err != nil { if err := r.ParseMultipartForm(32 << 20); err != nil {
return nil, err return nil, err
...@@ -106,7 +107,7 @@ func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error) { ...@@ -106,7 +107,7 @@ func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error) {
return files, nil return files, nil
} }
// readFileHeaderToTempFile reads multipart.FileHeader and writes it to a temporary file // readFileHeaderToTempFile reads multipart.FileHeader and writes it to a temporary file.
func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error) { func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error) {
formFile, err := fileHeader.Open() formFile, err := fileHeader.Open()
if err != nil { if err != nil {
...@@ -257,7 +258,7 @@ func parseNumericParameter[T Number](param string, fn Operation[T], checks ...Co ...@@ -257,7 +258,7 @@ func parseNumericParameter[T Number](param string, fn Operation[T], checks ...Co
return v, nil return v, nil
} }
// parseBoolParameter parses a string parameter to a bool // parseBoolParameter parses a string parameter to a bool.
func parseBoolParameter(param string, fn Operation[bool]) (bool, error) { func parseBoolParameter(param string, fn Operation[bool]) (bool, error) {
v, _, err := fn(param) v, _, err := fn(param)
return v, err return v, err
......
...@@ -34,7 +34,7 @@ import ( ...@@ -34,7 +34,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// rootCmd represents the base command when called without any subcommands // rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "ekms", Use: "ekms",
Short: "A brief description of your application", Short: "A brief description of your application",
......
...@@ -56,16 +56,16 @@ var ( ...@@ -56,16 +56,16 @@ var (
caFile string // the location of the file containing the ca certificate to verify client certificates caFile string // the location of the file containing the ca certificate to verify client certificates
keyFile string // the location of the file containing the key for the certificates for the gnmi server keyFile string // the location of the file containing the key for the certificates for the gnmi server
insecure *bool // set to true if insecure operations is needed, i.e., do not use TLS insecure *bool // set to true if insecure operations is needed, i.e., do not use TLS
// Below is qkdn specific information // Below is qkdn specific information.
udpQL1AddrString string udpQL1AddrString string
ql1Name string ql1Name string
udpQL2AddrString string udpQL2AddrString string
ql2Name string ql2Name string
kmsConfig string kmsConfig string
// End of qkdn specific information // End of qkdn specific information.
) )
// startCmd represents the start command // startCmd represents the start command.
var startCmd = &cobra.Command{ var startCmd = &cobra.Command{
Use: "start", Use: "start",
Short: "Start gnmi server", Short: "Start gnmi server",
......
...@@ -70,7 +70,7 @@ type EkmsClient interface { ...@@ -70,7 +70,7 @@ type EkmsClient interface {
} }
// TODO: change this in the future // TODO: change this in the future
// This provides some static information // This provides some static information.
type ekmsInfo struct { type ekmsInfo struct {
// Information used to fill the ETSI GS QKD 15 yang model // Information used to fill the ETSI GS QKD 15 yang model
id uuid.UUID id uuid.UUID
...@@ -97,7 +97,7 @@ func (evi *ekmsVersionInformation) HardwareVersion() string { ...@@ -97,7 +97,7 @@ func (evi *ekmsVersionInformation) HardwareVersion() string {
return evi.hwVersion return evi.hwVersion
} }
// A QkdnClient for the emulated KMS // A QkdnClient for the emulated KMS.
func NewEkmsClient(bootInfo *Config) (myInfo *ekmsInfo) { func NewEkmsClient(bootInfo *Config) (myInfo *ekmsInfo) {
var ekmsId uuid.UUID var ekmsId uuid.UUID
if bootInfo.Id != "" { if bootInfo.Id != "" {
...@@ -122,7 +122,7 @@ func NewEkmsClient(bootInfo *Config) (myInfo *ekmsInfo) { ...@@ -122,7 +122,7 @@ func NewEkmsClient(bootInfo *Config) (myInfo *ekmsInfo) {
return myInfo return myInfo
} }
// TODO: return an error // TODO: return an error.
func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKMS { func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKMS {
// Attach to eKMS // Attach to eKMS
emuKMS := kms.NewEKMS(config.Name, id, os.Stdout, log.TraceLevel, false, config.InterComAddr) emuKMS := kms.NewEKMS(config.Name, id, os.Stdout, log.TraceLevel, false, config.InterComAddr)
...@@ -137,6 +137,8 @@ func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKM ...@@ -137,6 +137,8 @@ func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKM
case "etsi": case "etsi":
qm, err = kms.NewETSI014HTTPQuantumModule(pqm.Address, pqm.SlaveSAEID, pqm.MasterSAEID, pqm.MasterMode) qm, err = kms.NewETSI014HTTPQuantumModule(pqm.Address, pqm.SlaveSAEID, pqm.MasterSAEID, pqm.MasterMode)
if err != nil { if err != nil {
log.Fatalf("Failed to create ETSI QKD module: %s", err)
return nil
} }
default: default:
log.Fatalf("Unknown type: %s for quantum module", qmt) log.Fatalf("Unknown type: %s for quantum module", qmt)
...@@ -145,7 +147,7 @@ func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKM ...@@ -145,7 +147,7 @@ func emulatedKMS(config *Config, id uuid.UUID, peerChannel chan string) *kms.EKM
err := emuKMS.AddQuantumElement(qm) err := emuKMS.AddQuantumElement(qm)
if err != nil { if err != nil {
log.Fatalf("Failed to add quantum element", err) log.Fatalf("Failed to add quantum element: %s", err)
return nil return nil
} }
......
...@@ -18,7 +18,7 @@ func (b *EventBus) Subscribe(topic Topic) (<-chan Event, error) { ...@@ -18,7 +18,7 @@ func (b *EventBus) Subscribe(topic Topic) (<-chan Event, error) {
subs, ok := b.subscribers[topic] subs, ok := b.subscribers[topic]
if !ok { if !ok {
initialSub := map[chan<- Event]struct{}{ initialSub := map[chan<- Event]struct{}{
newSubChan: struct{}{}, newSubChan: {},
} }
b.subscribers[topic] = initialSub b.subscribers[topic] = initialSub
} else if subs != nil { } else if subs != nil {
...@@ -35,7 +35,7 @@ func (b *EventBus) Publish(event Event) error { ...@@ -35,7 +35,7 @@ func (b *EventBus) Publish(event Event) error {
if !ok { if !ok {
return fmt.Errorf("There are no active subscribers for topic: %d", event.Topic()) return fmt.Errorf("There are no active subscribers for topic: %d", event.Topic())
} }
for sub, _ := range subs { for sub := range subs {
sub <- event sub <- event
} }
return nil return nil
......
...@@ -17,7 +17,7 @@ const ( ...@@ -17,7 +17,7 @@ const (
USED USED
) )
// holds a single ready to bit key, length can be configured // holds a single ready to bit key, length can be configured.
type kmsKSElement struct { type kmsKSElement struct {
keyID uuid.UUID keyID uuid.UUID
key []byte // a key key []byte // a key
...@@ -44,7 +44,7 @@ func (ks *kmsKeyStore) addKey(keyId uuid.UUID, keyToadd []byte) { ...@@ -44,7 +44,7 @@ func (ks *kmsKeyStore) addKey(keyId uuid.UUID, keyToadd []byte) {
// test for collisions // test for collisions
if _, notThere := ks.keyStore[keyId]; notThere { if _, notThere := ks.keyStore[keyId]; notThere {
log.Errorf("Whop: addKey collission of key id %s", keyId) log.Errorf("Whop: addKey collisions of key id %s", keyId)
return return
} }
......
// This package kms implements a simplistic key managment system (kms) for // This package kms implements a simplistic key management system (kms) for
// Quantum Key Distribution Networks (QKDN) which is a simple emulated KMS. x // Quantum Key Distribution Networks (QKDN) which is a simple emulated KMS. x
// It relies on the emulated quantum link out of the quantumlayer package // It relies on the emulated quantum link out of the quantumlayer package
...@@ -36,7 +36,7 @@ const ( ...@@ -36,7 +36,7 @@ const (
BitKeyLen512 BitKeyLength = "512" BitKeyLen512 BitKeyLength = "512"
) )
// The general emulated KMS // The general emulated KMS.
type EKMS struct { type EKMS struct {
kmsName string kmsName string
kmsUUID uuid.UUID kmsUUID uuid.UUID
...@@ -207,7 +207,7 @@ func (kms *EKMS) EventBus() *event.EventBus { ...@@ -207,7 +207,7 @@ func (kms *EKMS) EventBus() *event.EventBus {
return kms.eventBus return kms.eventBus
} }
// TODO/XXX error handling // TODO/XXX error handling.
func (kms *EKMS) RemovePeer(kmsPeerSocket string) { func (kms *EKMS) RemovePeer(kmsPeerSocket string) {
if _, there := kms.KmsPeers[kmsPeerSocket]; there { if _, there := kms.KmsPeers[kmsPeerSocket]; there {
// peer.quit <- true // peer.quit <- true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment