@@ -31,6 +31,7 @@ import (
31
31
32
32
"github.com/getkin/kin-openapi/openapi2"
33
33
"github.com/getkin/kin-openapi/openapi2conv"
34
+ "github.com/getkin/kin-openapi/openapi3"
34
35
"github.com/go-openapi/errors"
35
36
"github.com/go-openapi/runtime"
36
37
"github.com/go-openapi/runtime/middleware"
@@ -605,16 +606,15 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
605
606
606
607
// create stored consul instances
607
608
for _ , data := range cfg .ServiceDiscovery .Consuls {
608
- var err error
609
-
609
+ var errSD error
610
610
if data .ID == nil || len (* data .ID ) == 0 {
611
611
data .ID = service_discovery .NewServiceDiscoveryUUID ()
612
612
}
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 ())
615
615
}
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 ())
618
618
}
619
619
}
620
620
_ = cfg .SaveConsuls (cfg .ServiceDiscovery .Consuls )
@@ -662,7 +662,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
662
662
// setup OpenAPI v3 specification handler
663
663
api .SpecificationOpenapiv3GetOpenapiv3SpecificationHandler = specification_openapiv3 .GetOpenapiv3SpecificationHandlerFunc (func (params specification_openapiv3.GetOpenapiv3SpecificationParams , principal interface {}) middleware.Responder {
664
664
v2 := openapi2.Swagger {}
665
- err : = v2 .UnmarshalJSON (SwaggerJSON )
665
+ err = v2 .UnmarshalJSON (SwaggerJSON )
666
666
if err != nil {
667
667
e := misc .HandleError (err )
668
668
return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -675,7 +675,8 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
675
675
v2 .Host = cfg .RuntimeData .Host
676
676
}
677
677
678
- v3 , err := openapi2conv .ToV3Swagger (& v2 )
678
+ var v3 * openapi3.Swagger
679
+ v3 , err = openapi2conv .ToV3Swagger (& v2 )
679
680
if err != nil {
680
681
e := misc .HandleError (err )
681
682
return specification_openapiv3 .NewGetOpenapiv3SpecificationDefault (int (* e .Code )).WithPayload (e )
@@ -822,7 +823,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
822
823
options .Runtime (runtimeClient ),
823
824
}
824
825
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 )
826
828
if err != nil {
827
829
log .Fatalf ("error initializing map storage: %v" , err )
828
830
}
@@ -832,7 +834,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
832
834
}
833
835
834
836
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 )
836
839
if err != nil {
837
840
log .Fatalf ("error initializing SSL certs storage: %v" , err )
838
841
}
@@ -842,7 +845,8 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
842
845
}
843
846
844
847
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 )
846
850
if err != nil {
847
851
log .Fatalf ("error initializing General storage: %v" , err )
848
852
}
@@ -856,11 +860,12 @@ func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_conf
856
860
SpoeDir : haproxyOptions .SpoeDir ,
857
861
TransactionDir : haproxyOptions .SpoeTransactionDir ,
858
862
}
859
- spoe , err := spoe .NewSpoe (prms )
863
+ var spoeClient spoe.Spoe
864
+ spoeClient , err = spoe .NewSpoe (prms )
860
865
if err != nil {
861
866
log .Fatalf ("error setting up spoe: %v" , err )
862
867
}
863
- opt = append (opt , options .Spoe (spoe ))
868
+ opt = append (opt , options .Spoe (spoeClient ))
864
869
} else {
865
870
log .Fatalf ("error trying to use empty string for SPOE configuration directory" )
866
871
}
0 commit comments