From 297b93d441b166f1821551c2977a7daf274e27ff Mon Sep 17 00:00:00 2001 From: darkweak Date: Mon, 11 Mar 2024 12:27:10 +0100 Subject: [PATCH] feat(plugins): vendorize Traefik & Tyk --- plugins/traefik/override/middleware/middleware.go | 2 +- .../darkweak/souin/pkg/middleware/middleware.go | 2 +- .../darkweak/souin/pkg/surrogate/providers/akamai.go | 4 ++-- .../souin/pkg/surrogate/providers/cloudflare.go | 4 ++-- .../darkweak/souin/pkg/surrogate/providers/factory.go | 10 +++++----- .../darkweak/souin/pkg/surrogate/providers/fastly.go | 4 ++-- .../darkweak/souin/pkg/surrogate/providers/souin.go | 4 ++-- .../darkweak/souin/pkg/surrogate/surrogate.go | 4 ++-- plugins/tyk/override/middleware/middleware.go | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/traefik/override/middleware/middleware.go b/plugins/traefik/override/middleware/middleware.go index 2df92f90a..b9cd155da 100644 --- a/plugins/traefik/override/middleware/middleware.go +++ b/plugins/traefik/override/middleware/middleware.go @@ -32,7 +32,7 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S } fmt.Println("Storers initialized.") regexpUrls := helpers.InitializeRegexp(c) - surrogateStorage := surrogate.InitializeSurrogate(c) + surrogateStorage := surrogate.InitializeSurrogate(c, storers[0].Name()) fmt.Println("Surrogate storage initialized.") var excludedRegexp *regexp.Regexp = nil if c.GetDefaultCache().GetRegex().Exclude != "" { diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go index 2df92f90a..b9cd155da 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go @@ -32,7 +32,7 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S } fmt.Println("Storers initialized.") regexpUrls := helpers.InitializeRegexp(c) - surrogateStorage := surrogate.InitializeSurrogate(c) + surrogateStorage := surrogate.InitializeSurrogate(c, storers[0].Name()) fmt.Println("Surrogate storage initialized.") var excludedRegexp *regexp.Regexp = nil if c.GetDefaultCache().GetRegex().Exclude != "" { diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/akamai.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/akamai.go index 6fcb57128..2e35a9564 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/akamai.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/akamai.go @@ -14,7 +14,7 @@ type AkamaiSurrogateStorage struct { url string } -func generateAkamaiInstance(config configurationtypes.AbstractConfigurationInterface) *AkamaiSurrogateStorage { +func generateAkamaiInstance(config configurationtypes.AbstractConfigurationInterface, defaultStorerName string) *AkamaiSurrogateStorage { cdn := config.GetDefaultCache().GetCDN() a := &AkamaiSurrogateStorage{baseStorage: &baseStorage{}} @@ -28,7 +28,7 @@ func generateAkamaiInstance(config configurationtypes.AbstractConfigurationInter a.url += "/" + cdn.Network } - a.init(config) + a.init(config, defaultStorerName) a.parent = a return a diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/cloudflare.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/cloudflare.go index 4ec5cbfa4..f131ac900 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/cloudflare.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/cloudflare.go @@ -18,7 +18,7 @@ type CloudflareSurrogateStorage struct { zoneID string } -func generateCloudflareInstance(config configurationtypes.AbstractConfigurationInterface) *CloudflareSurrogateStorage { +func generateCloudflareInstance(config configurationtypes.AbstractConfigurationInterface, defaultStorerName string) *CloudflareSurrogateStorage { cdn := config.GetDefaultCache().GetCDN() f := &CloudflareSurrogateStorage{ baseStorage: &baseStorage{}, @@ -27,7 +27,7 @@ func generateCloudflareInstance(config configurationtypes.AbstractConfigurationI email: cdn.Email, } - f.init(config) + f.init(config, defaultStorerName) f.parent = f return f diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/factory.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/factory.go index 139a45374..3a6cf23fc 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/factory.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/factory.go @@ -5,17 +5,17 @@ import ( ) // SurrogateFactory generate a SurrogateInterface instance -func SurrogateFactory(config configurationtypes.AbstractConfigurationInterface) SurrogateInterface { +func SurrogateFactory(config configurationtypes.AbstractConfigurationInterface, defaultStorerName string) SurrogateInterface { cdn := config.GetDefaultCache().GetCDN() switch cdn.Provider { case "akamai": - return generateAkamaiInstance(config) + return generateAkamaiInstance(config, defaultStorerName) case "cloudflare": - return generateCloudflareInstance(config) + return generateCloudflareInstance(config, defaultStorerName) case "fastly": - return generateFastlyInstance(config) + return generateFastlyInstance(config, defaultStorerName) default: - return generateSouinInstance(config) + return generateSouinInstance(config, defaultStorerName) } } diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/fastly.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/fastly.go index 80139ad13..9067ce6ce 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/fastly.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/fastly.go @@ -15,7 +15,7 @@ type FastlySurrogateStorage struct { strategy string } -func generateFastlyInstance(config configurationtypes.AbstractConfigurationInterface) *FastlySurrogateStorage { +func generateFastlyInstance(config configurationtypes.AbstractConfigurationInterface, defaultStorerName string) *FastlySurrogateStorage { cdn := config.GetDefaultCache().GetCDN() f := &FastlySurrogateStorage{ baseStorage: &baseStorage{}, @@ -28,7 +28,7 @@ func generateFastlyInstance(config configurationtypes.AbstractConfigurationInter f.strategy = "1" } - f.init(config) + f.init(config, defaultStorerName) f.parent = f return f diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/souin.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/souin.go index e8eb26db7..693da2dd5 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/souin.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/providers/souin.go @@ -9,10 +9,10 @@ type SouinSurrogateStorage struct { *baseStorage } -func generateSouinInstance(config configurationtypes.AbstractConfigurationInterface) *SouinSurrogateStorage { +func generateSouinInstance(config configurationtypes.AbstractConfigurationInterface, defaultStorerName string) *SouinSurrogateStorage { s := &SouinSurrogateStorage{baseStorage: &baseStorage{}} - s.init(config) + s.init(config, defaultStorerName) s.parent = s return s diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/surrogate.go b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/surrogate.go index 3b9ab5487..6b015e2c7 100644 --- a/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/surrogate.go +++ b/plugins/traefik/vendor/github.com/darkweak/souin/pkg/surrogate/surrogate.go @@ -78,6 +78,6 @@ import ( ) // InitializeSurrogate will initialize the Surrogate-Key storage system -func InitializeSurrogate(configurationInterface configurationtypes.AbstractConfigurationInterface) providers.SurrogateInterface { - return providers.SurrogateFactory(configurationInterface) +func InitializeSurrogate(configurationInterface configurationtypes.AbstractConfigurationInterface, storageName string) providers.SurrogateInterface { + return providers.SurrogateFactory(configurationInterface, storageName) } diff --git a/plugins/tyk/override/middleware/middleware.go b/plugins/tyk/override/middleware/middleware.go index 1250bf82b..ff68a8f6d 100644 --- a/plugins/tyk/override/middleware/middleware.go +++ b/plugins/tyk/override/middleware/middleware.go @@ -61,7 +61,7 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S } c.GetLogger().Debug("Storer initialized.") regexpUrls := helpers.InitializeRegexp(c) - surrogateStorage := surrogate.InitializeSurrogate(c) + surrogateStorage := surrogate.InitializeSurrogate(c, storers[0].Name()) c.GetLogger().Debug("Surrogate storage initialized.") var excludedRegexp *regexp.Regexp = nil if c.GetDefaultCache().GetRegex().Exclude != "" {