@@ -31,6 +31,7 @@ import (
3131
3232 "github.com/getkin/kin-openapi/openapi2"
3333 "github.com/getkin/kin-openapi/openapi2conv"
34+ "github.com/getkin/kin-openapi/openapi3"
3435 "github.com/go-openapi/errors"
3536 "github.com/go-openapi/runtime"
3637 "github.com/go-openapi/runtime/middleware"
@@ -605,16 +606,15 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
605606
606607 // create stored consul instances
607608 for _ , data := range cfg .ServiceDiscovery .Consuls {
608- var err error
609-
609+ var errSD error
610610 if data .ID == nil || len (* data .ID ) == 0 {
611611 data .ID = service_discovery .NewServiceDiscoveryUUID ()
612612 }
613- if err = service_discovery .ValidateConsulData (data , true ); err != nil {
614- log .Fatalf ("Error validating Consul instance: " + err .Error ())
613+ if errSD = service_discovery .ValidateConsulData (data , true ); errSD != nil {
614+ log .Fatalf ("Error validating Consul instance: " + errSD .Error ())
615615 }
616- if err = discovery .AddNode ("consul" , * data .ID , data ); err != nil {
617- log .Warning ("Error creating consul instance: " + err .Error ())
616+ if errSD = discovery .AddNode ("consul" , * data .ID , data ); errSD != nil {
617+ log .Warning ("Error creating consul instance: " + errSD .Error ())
618618 }
619619 }
620620 _ = cfg .SaveConsuls (cfg .ServiceDiscovery .Consuls )
@@ -662,7 +662,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
662662 // setup OpenAPI v3 specification handler
663663 api .SpecificationOpenapiv3GetOpenapiv3SpecificationHandler = specification_openapiv3 .GetOpenapiv3SpecificationHandlerFunc (func (params specification_openapiv3.GetOpenapiv3SpecificationParams , principal interface {}) middleware.Responder {
664664 v2 := openapi2.Swagger {}
665- err : = v2 .UnmarshalJSON (SwaggerJSON )
665+ err = v2 .UnmarshalJSON (SwaggerJSON )
666666 if err != nil {
667667 e := misc .HandleError (err )
668668 return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -675,7 +675,8 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
675675 v2 .Host = cfg .RuntimeData .Host
676676 }
677677
678- v3 , err := openapi2conv .ToV3Swagger (& v2 )
678+ var v3 * openapi3.Swagger
679+ v3 , err = openapi2conv .ToV3Swagger (& v2 )
679680 if err != nil {
680681 e := misc .HandleError (err )
681682 return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -822,7 +823,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
822823 options .Runtime (runtimeClient ),
823824 }
824825 if haproxyOptions .MapsDir != "" {
825- mapStorage , err := storage .New (haproxyOptions .MapsDir , storage .MapsType )
826+ var mapStorage storage.Storage
827+ mapStorage , err = storage .New (haproxyOptions .MapsDir , storage .MapsType )
826828 if err != nil {
827829 log .Fatalf ("error initializing map storage: %v" , err )
828830 }
@@ -832,7 +834,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
832834 }
833835
834836 if haproxyOptions .SSLCertsDir != "" {
835- sslCertStorage , err := storage .New (haproxyOptions .SSLCertsDir , storage .SSLType )
837+ var sslCertStorage storage.Storage
838+ sslCertStorage , err = storage .New (haproxyOptions .SSLCertsDir , storage .SSLType )
836839 if err != nil {
837840 log .Fatalf ("error initializing SSL certs storage: %v" , err )
838841 }
@@ -842,7 +845,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
842845 }
843846
844847 if haproxyOptions .GeneralStorageDir != "" {
845- generalStorage , err := storage .New (haproxyOptions .GeneralStorageDir , storage .GeneralType )
848+ var generalStorage storage.Storage
849+ generalStorage , err = storage .New (haproxyOptions .GeneralStorageDir , storage .GeneralType )
846850 if err != nil {
847851 log .Fatalf ("error initializing General storage: %v" , err )
848852 }
@@ -856,11 +860,12 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
856860 SpoeDir : haproxyOptions .SpoeDir ,
857861 TransactionDir : haproxyOptions .SpoeTransactionDir ,
858862 }
859- spoe , err := spoe .NewSpoe (prms )
863+ var spoeClient spoe.Spoe
864+ spoeClient , err = spoe .NewSpoe (prms )
860865 if err != nil {
861866 log .Fatalf ("error setting up spoe: %v" , err )
862867 }
863- opt = append (opt , options .Spoe (spoe ))
868+ opt = append (opt , options .Spoe (spoeClient ))
864869 } else {
865870 log .Fatalf ("error trying to use empty string for SPOE configuration directory" )
866871 }
0 commit comments