@@ -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"
@@ -625,16 +626,15 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
625626
626627 // create stored consul instances
627628 for _ , data := range cfg .ServiceDiscovery .Consuls {
628- var err error
629-
629+ var errSD error
630630 if data .ID == nil || len (* data .ID ) == 0 {
631631 data .ID = service_discovery .NewServiceDiscoveryUUID ()
632632 }
633- if err = service_discovery .ValidateConsulData (data , true ); err != nil {
634- log .Fatalf ("Error validating Consul instance: " + err .Error ())
633+ if errSD = service_discovery .ValidateConsulData (data , true ); errSD != nil {
634+ log .Fatalf ("Error validating Consul instance: " + errSD .Error ())
635635 }
636- if err = discovery .AddNode ("consul" , * data .ID , data ); err != nil {
637- log .Warning ("Error creating consul instance: " + err .Error ())
636+ if errSD = discovery .AddNode ("consul" , * data .ID , data ); errSD != nil {
637+ log .Warning ("Error creating consul instance: " + errSD .Error ())
638638 }
639639 }
640640 _ = cfg .SaveConsuls (cfg .ServiceDiscovery .Consuls )
@@ -682,7 +682,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
682682 // setup OpenAPI v3 specification handler
683683 api .SpecificationOpenapiv3GetOpenapiv3SpecificationHandler = specification_openapiv3 .GetOpenapiv3SpecificationHandlerFunc (func (params specification_openapiv3.GetOpenapiv3SpecificationParams , principal interface {}) middleware.Responder {
684684 v2 := openapi2.Swagger {}
685- err : = v2 .UnmarshalJSON (SwaggerJSON )
685+ err = v2 .UnmarshalJSON (SwaggerJSON )
686686 if err != nil {
687687 e := misc .HandleError (err )
688688 return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -695,7 +695,8 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
695695 v2 .Host = cfg .RuntimeData .Host
696696 }
697697
698- v3 , err := openapi2conv .ToV3Swagger (& v2 )
698+ var v3 * openapi3.Swagger
699+ v3 , err = openapi2conv .ToV3Swagger (& v2 )
699700 if err != nil {
700701 e := misc .HandleError (err )
701702 return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -842,7 +843,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
842843 options .Runtime (runtimeClient ),
843844 }
844845 if haproxyOptions .MapsDir != "" {
845- mapStorage , err := storage .New (haproxyOptions .MapsDir , storage .MapsType )
846+ var mapStorage storage.Storage
847+ mapStorage , err = storage .New (haproxyOptions .MapsDir , storage .MapsType )
846848 if err != nil {
847849 log .Fatalf ("error initializing map storage: %v" , err )
848850 }
@@ -852,7 +854,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
852854 }
853855
854856 if haproxyOptions .SSLCertsDir != "" {
855- sslCertStorage , err := storage .New (haproxyOptions .SSLCertsDir , storage .SSLType )
857+ var sslCertStorage storage.Storage
858+ sslCertStorage , err = storage .New (haproxyOptions .SSLCertsDir , storage .SSLType )
856859 if err != nil {
857860 log .Fatalf ("error initializing SSL certs storage: %v" , err )
858861 }
@@ -862,7 +865,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
862865 }
863866
864867 if haproxyOptions .GeneralStorageDir != "" {
865- generalStorage , err := storage .New (haproxyOptions .GeneralStorageDir , storage .GeneralType )
868+ var generalStorage storage.Storage
869+ generalStorage , err = storage .New (haproxyOptions .GeneralStorageDir , storage .GeneralType )
866870 if err != nil {
867871 log .Fatalf ("error initializing General storage: %v" , err )
868872 }
@@ -876,11 +880,12 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
876880 SpoeDir : haproxyOptions .SpoeDir ,
877881 TransactionDir : haproxyOptions .SpoeTransactionDir ,
878882 }
879- spoe , err := spoe .NewSpoe (prms )
883+ var spoeClient spoe.Spoe
884+ spoeClient , err = spoe .NewSpoe (prms )
880885 if err != nil {
881886 log .Fatalf ("error setting up spoe: %v" , err )
882887 }
883- opt = append (opt , options .Spoe (spoe ))
888+ opt = append (opt , options .Spoe (spoeClient ))
884889 } else {
885890 log .Fatalf ("error trying to use empty string for SPOE configuration directory" )
886891 }
0 commit comments