Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • danet/quant
1 result
Select Git revision
Show changes
Commits on Source (18)
Showing
with 240 additions and 130 deletions
stages: stages:
- build - build
- code-quality
variables: variables:
IMAGE_PATH: "${CI_REGISTRY_IMAGE}" IMAGE_PATH: "${CI_REGISTRY_IMAGE}"
...@@ -21,14 +22,23 @@ variables: ...@@ -21,14 +22,23 @@ variables:
build-ekms: build-ekms:
script: script:
- IMAGE_NAME="$IMAGE_PATH/ekms" - IMAGE_NAME="$IMAGE_PATH/ekms"
- TAG=$CI_COMMIT_REF_SLUG - TAG=$CI_COMMIT_REF_SLUG
- docker buildx build --push -t "$IMAGE_NAME:$TAG" -f ekms/Dockerfile --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . - docker buildx build --push -t "$IMAGE_NAME:$TAG" -f ekms/Dockerfile --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} .
<<: *build <<: *build
build-quantumlayer: build-quantumlayer:
script: script:
- IMAGE_NAME="$IMAGE_PATH/quantumlayer" - IMAGE_NAME="$IMAGE_PATH/quantumlayer"
- TAG=$CI_COMMIT_REF_SLUG - TAG=$CI_COMMIT_REF_SLUG
- docker buildx build --push -t "$IMAGE_NAME:$TAG" -f quantumlayer/Dockerfile --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . - docker buildx build --push -t "$IMAGE_NAME:$TAG" -f quantumlayer/Dockerfile --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} .
<<: *build <<: *build
lint:
stage: code-quality
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golangci/golangci-lint:v1.55.2-alpine
script:
# writes golangci-lint output to gl-code-quality-report.json
- apk add --update make jq
- make ci-lint
needs: []
variables:
GOLANG_VERSION: "1.21"
run:
go: $GOLANG_VERSION
concurrency: 8
timeout: 20m
issues-exit-code: 1
# directories to be ignored by linters
skip-dirs:
- .git/
- ekms/model
- ekms/models
- artifacts/
skip-dirs-default: true
#skip-files:
# - http.go
modules-download-mode: readonly
# output settings -> code-climate for GitLab
output:
format: code-climate
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
path-prefix: ""
issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
linters:
# enable the specific needed linters
# see here for full list: https://golangci-lint.run/usage/linters/
# linters to consider: gosimple, containedctx, contextcheck, depguard, errchkjson, exhaustive, exhaustruct, forbidigo,
# gochecknoinits, gocognit, goconst, gocritic, gofumpt, gomnd, gosec, importas, lll, nestif, nilerr, nlreturn, noctx, nolintlint,
# nosnakecase, paralleltest, prealloc, structcheck, testpackage, tparallel, unparam, wastedassign, wrapcheck, wsl
disable-all: true
enable:
- gofmt
- goimports
- gocyclo
- govet
- unused
- staticcheck
- typecheck
- revive
- whitespace
- errcheck
- ineffassign
- bidichk
- durationcheck
- errorlint
- exportloopref
- grouper
- makezero
- misspell
- nilnil
- predeclared
- godot
- errname
# custom settings for linters
linters-settings:
gocyclo:
min-complexity: 15
golint:
min-confidence: 0.8
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
revive:
severity: warning
confidence: 0.8
...@@ -7,7 +7,9 @@ TOOLS_DIR:= build-tools ...@@ -7,7 +7,9 @@ TOOLS_DIR:= build-tools
GOSDN_PRG := $(MAKEFILE_DIR)$(TOOLS_DIR) GOSDN_PRG := $(MAKEFILE_DIR)$(TOOLS_DIR)
GOPATH := $(~/go) GOPATH := $(~/go)
GOBIN := $(GOSDN_PRG) GOBIN := $(GOSDN_PRG)
GOLANG_VERSION := 1.21 GOLANG_VERSION := 1.21
GOLANGCI_LINT_VERSION=v1.55.0
GOCMD=go GOCMD=go
GOBUILD=$(GOCMD) build GOBUILD=$(GOCMD) build
...@@ -24,10 +26,21 @@ pre: ...@@ -24,10 +26,21 @@ pre:
install-tools: install-tools:
@echo Install development tooling @echo Install development tooling
mkdir -p $(GOSDN_PRG) mkdir -p $(GOSDN_PRG)
export GOBIN=$(GOSDN_PRG) && go install github.com/openconfig/ygot/generator@v0.28.3 &&\ export GOBIN=$(GOSDN_PRG) &&\
go install github.com/andresterba/go-ygot-generator-generator@v0.0.4 go install github.com/openconfig/ygot/generator@v0.28.3 &&\
go install github.com/andresterba/go-ygot-generator-generator@v0.0.4 &&\
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
@echo Finished installing development tooling @echo Finished installing development tooling
lint: install-tools
./$(TOOLS_DIR)/golangci-lint run --config .golangci.yml | jq
lint-fix: install-tools
./$(TOOLS_DIR)/golangci-lint run --config .golangci.yml --fix | jq
ci-lint:
golangci-lint run --config .golangci.yml --out-format code-climate
build-ekms: pre build-ekms: pre
CGO_ENABLED=0 $(GOBUILD) -o $(BUILD_ARTIFACTS_PATH)/ekms ./ekms/main.go CGO_ENABLED=0 $(GOBUILD) -o $(BUILD_ARTIFACTS_PATH)/ekms ./ekms/main.go
......
...@@ -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,22 +80,22 @@ func (c *DefaultAPIController) Routes() Routes { ...@@ -80,22 +80,22 @@ 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()
slaveSAEIDParam := params["slave_SAE_ID"] slaveSAEIDParam := params["slave_SAE_ID"]
numberParam, err := parseNumericParameter[int64]( numberParam, err := ParseNumericParameter[int64](
query.Get("number"), query.Get("number"),
WithParse[int64](parseInt64), WithParse[int64](ParseInt64),
) )
if err != nil { if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil) c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return return
} }
sizeParam, err := parseNumericParameter[int64]( sizeParam, err := ParseNumericParameter[int64](
query.Get("size"), query.Get("size"),
WithParse[int64](parseInt64), WithParse[int64](ParseInt64),
) )
if err != nil { if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil) c.errorHandler(w, r, &ParsingError{Err: err}, nil)
...@@ -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 {
...@@ -138,8 +139,8 @@ type Number interface { ...@@ -138,8 +139,8 @@ type Number interface {
type ParseString[T Number | string | bool] func(v string) (T, error) type ParseString[T Number | string | bool] func(v string) (T, error)
// parseFloat64 parses a string parameter to an float64. // ParseFloat64 parses a string parameter to an float64.
func parseFloat64(param string) (float64, error) { func ParseFloat64(param string) (float64, error) {
if param == "" { if param == "" {
return 0, nil return 0, nil
} }
...@@ -147,8 +148,8 @@ func parseFloat64(param string) (float64, error) { ...@@ -147,8 +148,8 @@ func parseFloat64(param string) (float64, error) {
return strconv.ParseFloat(param, 64) return strconv.ParseFloat(param, 64)
} }
// parseFloat32 parses a string parameter to an float32. // ParseFloat32 parses a string parameter to an float32.
func parseFloat32(param string) (float32, error) { func ParseFloat32(param string) (float32, error) {
if param == "" { if param == "" {
return 0, nil return 0, nil
} }
...@@ -157,8 +158,8 @@ func parseFloat32(param string) (float32, error) { ...@@ -157,8 +158,8 @@ func parseFloat32(param string) (float32, error) {
return float32(v), err return float32(v), err
} }
// parseInt64 parses a string parameter to an int64. // ParseInt64 parses a string parameter to an int64.
func parseInt64(param string) (int64, error) { func ParseInt64(param string) (int64, error) {
if param == "" { if param == "" {
return 0, nil return 0, nil
} }
...@@ -166,8 +167,8 @@ func parseInt64(param string) (int64, error) { ...@@ -166,8 +167,8 @@ func parseInt64(param string) (int64, error) {
return strconv.ParseInt(param, 10, 64) return strconv.ParseInt(param, 10, 64)
} }
// parseInt32 parses a string parameter to an int32. // ParseInt32 parses a string parameter to an int32.
func parseInt32(param string) (int32, error) { func ParseInt32(param string) (int32, error) {
if param == "" { if param == "" {
return 0, nil return 0, nil
} }
...@@ -176,8 +177,8 @@ func parseInt32(param string) (int32, error) { ...@@ -176,8 +177,8 @@ func parseInt32(param string) (int32, error) {
return int32(val), err return int32(val), err
} }
// parseBool parses a string parameter to an bool. // ParseBool parses a string parameter to an bool.
func parseBool(param string) (bool, error) { func ParseBool(param string) (bool, error) {
if param == "" { if param == "" {
return false, nil return false, nil
} }
...@@ -239,8 +240,8 @@ func WithMaximum[T Number](expected T) Constraint[T] { ...@@ -239,8 +240,8 @@ func WithMaximum[T Number](expected T) Constraint[T] {
} }
} }
// parseNumericParameter parses a numeric parameter to its respective type. // ParseNumericParameter parses a numeric parameter to its respective type.
func parseNumericParameter[T Number](param string, fn Operation[T], checks ...Constraint[T]) (T, error) { func ParseNumericParameter[T Number](param string, fn Operation[T], checks ...Constraint[T]) (T, error) {
v, ok, err := fn(param) v, ok, err := fn(param)
if err != nil { if err != nil {
return 0, err return 0, err
...@@ -257,14 +258,14 @@ func parseNumericParameter[T Number](param string, fn Operation[T], checks ...Co ...@@ -257,14 +258,14 @@ 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
} }
// parseNumericArrayParameter parses a string parameter containing array of values to its respective type. // ParseNumericArrayParameter parses a string parameter containing array of values to its respective type.
func parseNumericArrayParameter[T Number](param, delim string, required bool, fn Operation[T], checks ...Constraint[T]) ([]T, error) { func ParseNumericArrayParameter[T Number](param, delim string, required bool, fn Operation[T], checks ...Constraint[T]) ([]T, error) {
if param == "" { if param == "" {
if required { if required {
return nil, errors.New(errMsgRequiredMissing) return nil, errors.New(errMsgRequiredMissing)
......
...@@ -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",
...@@ -142,19 +142,58 @@ func init() { ...@@ -142,19 +142,58 @@ func init() {
startCmd.Flags().StringVarP(&ql2Name, "remote_name", "", "ekms-ql2", "The name of the remote quantumlayer") startCmd.Flags().StringVarP(&ql2Name, "remote_name", "", "ekms-ql2", "The name of the remote quantumlayer")
startCmd.Flags().StringVarP(&kmsConfig, "kms_config", "", "", "Path to the kms config file (yaml)") startCmd.Flags().StringVarP(&kmsConfig, "kms_config", "", "", "Path to the kms config file (yaml)")
viper.BindPFlag("bindAddress", startCmd.Flags().Lookup("bind_address")) err := viper.BindPFlag("bindAddress", startCmd.Flags().Lookup("bind_address"))
viper.BindPFlag("configFile", startCmd.Flags().Lookup("config")) if err != nil {
viper.BindPFlag("logLevel", startCmd.Flags().Lookup("log")) fmt.Println(err)
viper.BindPFlag("insecure", startCmd.Flags().Lookup("insecure")) }
viper.BindPFlag("certFile", startCmd.Flags().Lookup("cert")) err = viper.BindPFlag("configFile", startCmd.Flags().Lookup("config"))
viper.BindPFlag("keyFile", startCmd.Flags().Lookup("key")) if err != nil {
viper.BindPFlag("caFile", startCmd.Flags().Lookup("ca_file")) fmt.Println(err)
viper.BindPFlag("osclient", startCmd.Flags().Lookup("osclient")) }
viper.BindPFlag("my_QLE_socket", startCmd.Flags().Lookup("my-address")) err = viper.BindPFlag("logLevel", startCmd.Flags().Lookup("log"))
viper.BindPFlag("my_name", startCmd.Flags().Lookup("my-name")) if err != nil {
viper.BindPFlag("remote_QLE_socket", startCmd.Flags().Lookup("remote-address")) fmt.Println(err)
viper.BindPFlag("remote_name", startCmd.Flags().Lookup("remote-name")) }
viper.BindPFlag("kms-config", startCmd.Flags().Lookup("kms_config")) err = viper.BindPFlag("insecure", startCmd.Flags().Lookup("insecure"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("certFile", startCmd.Flags().Lookup("cert"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("keyFile", startCmd.Flags().Lookup("key"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("caFile", startCmd.Flags().Lookup("ca_file"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("osclient", startCmd.Flags().Lookup("osclient"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("my_QLE_socket", startCmd.Flags().Lookup("my-address"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("my_name", startCmd.Flags().Lookup("my-name"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("remote_QLE_socket", startCmd.Flags().Lookup("remote-address"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("remote_name", startCmd.Flags().Lookup("remote-name"))
if err != nil {
fmt.Println(err)
}
err = viper.BindPFlag("kms-config", startCmd.Flags().Lookup("kms_config"))
if err != nil {
fmt.Println(err)
}
rootCmd.AddCommand(startCmd) rootCmd.AddCommand(startCmd)
} }
...@@ -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
} }
......