1
0
mirror of https://github.com/containous/traefik.git synced 2025-09-23 17:44:46 +03:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Fernandez Ludovic
fe4d0e95b3 Prepare release v1.3.1 2017-06-16 12:53:26 +02:00
Fernandez Ludovic
0fb63f4488 fix(webui): don't fail when backend or frontend are empty. 2017-06-16 10:38:58 +02:00
Fernandez Ludovic
d87c4d89e9 fix: Double GZIP. 2017-06-14 21:13:38 +02:00
Fernandez Ludovic
ccc429e36c refactor(eureka): Use Traefik Logger. 2017-06-14 19:49:45 +02:00
Fernandez Ludovic
0d25ba3cbc refactor: Add explicit error message. 2017-06-14 19:49:45 +02:00
Kekoa Vincent
ac5ab13a4c Fix errors caused by incorrect type being sent for the Kubernetes Secret watcher #1596
This was likely just a copy-paste issue, the bug should be benign because the secret is cast to the correct type later, but the additional logging is a major annoyance, and is happening even if basic auth is not in use with Kubernetes.
2017-06-02 19:20:47 +02:00
Maxime Guyot
1db22a6e63 Fix capitalization of PathPrefixStrip in kubernetes doc 2017-06-01 20:40:28 +02:00
9 changed files with 136 additions and 36 deletions

View File

@@ -1,5 +1,19 @@
# Change Log
## [v1.3.1](https://github.com/containous/traefik/tree/v1.3.1) (2017-06-16)
[All Commits](https://github.com/containous/traefik/compare/v1.3.0...v1.3.1)
**Enhancements:**
- **[logs,eureka,marathon]** Minor logs changes ([#1749](https://github.com/containous/traefik/pull/1749) by [ldez](https://github.com/ldez))
**Bug fixes:**
- **[k8s]** Use correct type when watching for k8s secrets ([#1700](https://github.com/containous/traefik/pull/1700) by [kekoav](https://github.com/kekoav))
- **[middleware]** fix: Double compression. ([#1714](https://github.com/containous/traefik/pull/1714) by [ldez](https://github.com/ldez))
- **[webui]** Don't fail when backend or frontend are empty. ([#1757](https://github.com/containous/traefik/pull/1757) by [ldez](https://github.com/ldez))
**Documentation:**
- **[k8s]** Fix capitalization of PathPrefixStrip in kubernetes doc ([#1695](https://github.com/containous/traefik/pull/1695) by [Miouge1](https://github.com/Miouge1))
## [v1.3.0](https://github.com/containous/traefik/tree/v1.3.0) (2017-05-31)
[All Commits](https://github.com/containous/traefik/compare/v1.2.0-rc1...v1.3.0)

View File

@@ -471,7 +471,7 @@ metadata:
name: cheeses
annotations:
kubernetes.io/ingress.class: traefik
traefik.frontend.rule.type: pathprefixstrip
traefik.frontend.rule.type: PathPrefixStrip
spec:
rules:
- host: cheeses.local

View File

@@ -3,7 +3,7 @@ kind: Ingress
metadata:
name: cheeses
annotations:
traefik.frontend.rule.type: pathprefixstrip
traefik.frontend.rule.type: PathPrefixStrip
spec:
rules:
- host: cheeses.local

View File

@@ -6,12 +6,26 @@ import (
"github.com/NYTimes/gziphandler"
)
// Compress is a middleware that allows redirections
type Compress struct {
const (
contentEncodingHeader = "Content-Encoding"
)
// Compress is a middleware that allows redirection
type Compress struct{}
// ServerHTTP is a function used by Negroni
func (c *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
if isEncoded(r.Header) {
next.ServeHTTP(rw, r)
} else {
newGzipHandler := gziphandler.GzipHandler(next)
newGzipHandler.ServeHTTP(rw, r)
}
}
// ServerHTTP is a function used by negroni
func (c *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
newGzipHandler := gziphandler.GzipHandler(next)
newGzipHandler.ServeHTTP(rw, r)
func isEncoded(headers http.Header) bool {
header := headers.Get(contentEncodingHeader)
// According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding,
// content is not encoded if the header 'Content-Encoding' is empty or equals to 'identity'.
return header != "" && header != "identity"
}

View File

@@ -0,0 +1,69 @@
package middlewares
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/NYTimes/gziphandler"
"github.com/containous/traefik/testhelpers"
"github.com/stretchr/testify/assert"
)
const (
acceptEncodingHeader = "Accept-Encoding"
varyHeader = "Vary"
gzip = "gzip"
)
func TestShouldCompressWhenNoContentEncodingHeader(t *testing.T) {
handler := &Compress{}
req := testhelpers.MustNewRequest(http.MethodGet, "http://localhost", nil)
req.Header.Add(acceptEncodingHeader, gzip)
baseBody := generateBytes(gziphandler.DefaultMinSize)
next := func(rw http.ResponseWriter, r *http.Request) {
rw.Write(baseBody)
}
rw := httptest.NewRecorder()
handler.ServeHTTP(rw, req, next)
assert.Equal(t, gzip, rw.Header().Get(contentEncodingHeader))
assert.Equal(t, acceptEncodingHeader, rw.Header().Get(varyHeader))
if assert.ObjectsAreEqualValues(rw.Body.Bytes(), baseBody) {
assert.Fail(t, "expected a compressed body", "got %v", rw.Body.Bytes())
}
}
func TestShouldNotCompressWhenContentEncodingHeader(t *testing.T) {
handler := &Compress{}
req := testhelpers.MustNewRequest(http.MethodGet, "http://localhost", nil)
req.Header.Add(acceptEncodingHeader, gzip)
req.Header.Add(contentEncodingHeader, gzip)
baseBody := generateBytes(gziphandler.DefaultMinSize)
next := func(rw http.ResponseWriter, r *http.Request) {
rw.Write(baseBody)
}
rw := httptest.NewRecorder()
handler.ServeHTTP(rw, req, next)
assert.Equal(t, "", rw.Header().Get(contentEncodingHeader))
assert.Equal(t, "", rw.Header().Get(varyHeader))
assert.EqualValues(t, rw.Body.Bytes(), baseBody)
}
func generateBytes(len int) []byte {
var value []byte
for i := 0; i < len; i++ {
value = append(value, 0x61)
}
return value
}

View File

@@ -8,9 +8,9 @@ import (
"time"
"github.com/ArthurHlt/go-eureka-client/eureka"
log "github.com/Sirupsen/logrus"
"github.com/cenk/backoff"
"github.com/containous/traefik/job"
"github.com/containous/traefik/log"
"github.com/containous/traefik/provider"
"github.com/containous/traefik/safe"
"github.com/containous/traefik/types"

View File

@@ -221,7 +221,7 @@ func (c *clientImpl) WatchSecrets(watchCh chan<- interface{}, stopCh <-chan stru
c.secStore, c.secController = cache.NewInformer(
source,
&v1.Endpoints{},
&v1.Secret{},
resyncPeriod,
newResourceEventHandlerFuncs(watchCh))
go c.secController.Run(stopCh)

View File

@@ -166,13 +166,13 @@ func (p *Provider) loadMarathonConfig() *types.Configuration {
applications, err := p.marathonClient.Applications(nil)
if err != nil {
log.Errorf("Failed to create a client for marathon, error: %s", err)
log.Errorf("Failed to retrieve applications from Marathon, error: %s", err)
return nil
}
tasks, err := p.marathonClient.AllTasks(&marathon.AllTasksOpts{Status: "running"})
if err != nil {
log.Errorf("Failed to create a client for marathon, error: %s", err)
log.Errorf("Failed to retrieve task from Marathon, error: %s", err)
return nil
}

View File

@@ -12,34 +12,37 @@ angular
function Providers($resource, $q) {
const resourceProvider = $resource('../api/providers');
return {
get: function() {
get: function () {
return $q((resolve, reject) => {
resourceProvider.get().$promise.then((rawProviders) => {
for (let providerName in rawProviders) {
if (rawProviders.hasOwnProperty(providerName)) {
if (!providerName.startsWith('$')) {
// BackEnds mapping
let bckends = rawProviders[providerName].backends;
resourceProvider.get()
.$promise
.then((rawProviders) => {
for (let providerName in rawProviders) {
if (rawProviders.hasOwnProperty(providerName)) {
if (!providerName.startsWith('$')) {
// BackEnds mapping
let bckends = rawProviders[providerName].backends || {};
rawProviders[providerName].backends = Object.keys(bckends)
.map(key => {
const goodBackend = bckends[key];
goodBackend.backendId = key;
return goodBackend;
});
rawProviders[providerName].backends = Object.keys(bckends).map(key => {
const goodBackend = bckends[key];
goodBackend.backendId = key;
return goodBackend;
});
// FrontEnds mapping
let frtends = rawProviders[providerName].frontends;
rawProviders[providerName].frontends = Object.keys(frtends).map(key => {
const goodFrontend = frtends[key];
goodFrontend.frontendId = key;
return goodFrontend;
});
// FrontEnds mapping
let frtends = rawProviders[providerName].frontends || {};
rawProviders[providerName].frontends = Object.keys(frtends)
.map(key => {
const goodFrontend = frtends[key];
goodFrontend.frontendId = key;
return goodFrontend;
});
}
}
}
}
resolve(rawProviders);
}).catch(reject);
resolve(rawProviders);
})
.catch(reject);
});
}
};