From 5774d100c1857438272824b77aee90cd1868eec9 Mon Sep 17 00:00:00 2001 From: SALLEYRON Julien Date: Fri, 13 Jul 2018 18:04:03 +0200 Subject: [PATCH] Update service fabric --- Gopkg.lock | 7 ++--- Gopkg.toml | 2 +- .../servicefabric.go | 30 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 8c7a21475..c2a3bbbc8 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -276,10 +276,10 @@ version = "v3.1.1" [[projects]] - branch = "init-provider" name = "github.com/containous/traefik-extra-service-fabric" packages = ["."] - revision = "eb4d5cf161b3213bf45be611dc1f56e8b2161e46" + revision = "6e90a9eef2ac9d320e55d6e994d169673a8d8b0f" + version = "v1.3.0" [[projects]] name = "github.com/coreos/bbolt" @@ -781,7 +781,6 @@ revision = "9b66602d496a139e4722bdde32f0f1ac1c12d4a8" [[projects]] - branch = "master" name = "github.com/jjcollinge/servicefabric" packages = ["."] revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe" @@ -1756,6 +1755,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "c228c6029e36e15b6c74bdfa587ee0fa39787af0dc0d4047752d80ee2fb690c1" + inputs-digest = "2b7ffb1d01d8a14224fcc9964900fb5a39fbf38cfacba45f49b931136e4fee9b" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index a5ade8e33..3daa4cf4e 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -66,7 +66,7 @@ [[constraint]] name = "github.com/containous/traefik-extra-service-fabric" - branch = "init-provider" + version = "1.3.0" [[constraint]] name = "github.com/coreos/go-systemd" diff --git a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go index 8ae139884..bb7c3fb37 100644 --- a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go +++ b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go @@ -39,17 +39,16 @@ type Provider struct { AppInsightsKey string `description:"Application Insights Instrumentation Key"` AppInsightsBatchSize int `description:"Number of trace lines per batch, optional"` AppInsightsInterval flaeg.Duration `description:"The interval for sending data to Application Insights, optional"` + sfClient sfClient } // Init the provider func (p *Provider) Init(constraints types.Constraints) error { - p.BaseProvider.Init(constraints) - return nil -} + err := p.BaseProvider.Init(constraints) + if err != nil { + return err + } -// Provide allows the ServiceFabric provider to provide configurations to traefik -// using the given configuration channel. -func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool) error { if p.APIVersion == "" { p.APIVersion = sf.DefaultAPIVersion } @@ -59,7 +58,7 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s return err } - sfClient, err := sf.NewClient(http.DefaultClient, p.ClusterManagementURL, p.APIVersion, tlsConfig) + p.sfClient, err = sf.NewClient(http.DefaultClient, p.ClusterManagementURL, p.APIVersion, tlsConfig) if err != nil { return err } @@ -77,11 +76,16 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s } createAppInsightsHook(p.AppInsightsClientName, p.AppInsightsKey, p.AppInsightsBatchSize, p.AppInsightsInterval) } - - return p.updateConfig(configurationChan, pool, sfClient, time.Duration(p.RefreshSeconds)) + return nil } -func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, sfClient sfClient, pollInterval time.Duration) error { +// Provide allows the ServiceFabric provider to provide configurations to traefik +// using the given configuration channel. +func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool) error { + return p.updateConfig(configurationChan, pool, time.Duration(p.RefreshSeconds)) +} + +func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, pollInterval time.Duration) error { pool.Go(func(stop chan bool) { operation := func() error { ticker := time.NewTicker(pollInterval) @@ -96,7 +100,7 @@ func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, po log.Info("Checking service fabric config") } - configuration, err := p.getConfiguration(sfClient) + configuration, err := p.getConfiguration() if err != nil { return err } @@ -120,8 +124,8 @@ func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, po return nil } -func (p *Provider) getConfiguration(sfClient sfClient) (*types.Configuration, error) { - services, err := getClusterServices(sfClient) +func (p *Provider) getConfiguration() (*types.Configuration, error) { + services, err := getClusterServices(p.sfClient) if err != nil { return nil, err }