From 8d8717d421b01cb713d73e823e0d6c527447dce6 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 29 May 2023 13:04:05 +0200 Subject: [PATCH 1/5] Update go-acme/lego to v4.12.0 --- docs/content/https/acme.md | 1 + go.mod | 18 +++++++++--------- go.sum | 36 ++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/docs/content/https/acme.md b/docs/content/https/acme.md index 3e1f8345e..1392092bb 100644 --- a/docs/content/https/acme.md +++ b/docs/content/https/acme.md @@ -329,6 +329,7 @@ For complete details, refer to your provider's _Additional configuration_ link. | [CloudXNS](https://www.cloudxns.net) | `cloudxns` | `CLOUDXNS_API_KEY`, `CLOUDXNS_SECRET_KEY` | [Additional configuration](https://go-acme.github.io/lego/dns/cloudxns) | | [ConoHa](https://www.conoha.jp) | `conoha` | `CONOHA_TENANT_ID`, `CONOHA_API_USERNAME`, `CONOHA_API_PASSWORD` | [Additional configuration](https://go-acme.github.io/lego/dns/conoha) | | [Constellix](https://constellix.com) | `constellix` | `CONSTELLIX_API_KEY`, `CONSTELLIX_SECRET_KEY` | [Additional configuration](https://go-acme.github.io/lego/dns/constellix) | +| [Derak Cloud](https://derak.cloud/) | `derak` | `DERAK_API_KEY` | [Additional configuration](https://go-acme.github.io/lego/dns/derak) | | [deSEC](https://desec.io) | `desec` | `DESEC_TOKEN` | [Additional configuration](https://go-acme.github.io/lego/dns/desec) | | [DigitalOcean](https://www.digitalocean.com) | `digitalocean` | `DO_AUTH_TOKEN` | [Additional configuration](https://go-acme.github.io/lego/dns/digitalocean) | | [DNS Made Easy](https://dnsmadeeasy.com) | `dnsmadeeasy` | `DNSMADEEASY_API_KEY`, `DNSMADEEASY_API_SECRET`, `DNSMADEEASY_SANDBOX` | [Additional configuration](https://go-acme.github.io/lego/dns/dnsmadeeasy) | diff --git a/go.mod b/go.mod index 95d703af5..06a0f01f1 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/docker/go-connections v0.4.0 github.com/fatih/structs v1.1.0 github.com/gambol99/go-marathon v0.0.0-20180614232016-99a156b96fb2 - github.com/go-acme/lego/v4 v4.11.0 + github.com/go-acme/lego/v4 v4.12.0 github.com/go-check/check v0.0.0-00010101000000-000000000000 github.com/go-kit/kit v0.10.1-0.20200915143503-439c4d2ed3ea github.com/golang/protobuf v1.5.2 @@ -70,11 +70,11 @@ require ( github.com/vulcand/predicate v1.2.0 go.elastic.co/apm v1.13.1 go.elastic.co/apm/module/apmot v1.13.1 - golang.org/x/mod v0.6.0 - golang.org/x/net v0.7.0 - golang.org/x/text v0.7.0 + golang.org/x/mod v0.8.0 + golang.org/x/net v0.8.0 + golang.org/x/text v0.8.0 golang.org/x/time v0.3.0 - golang.org/x/tools v0.2.0 + golang.org/x/tools v0.6.0 google.golang.org/grpc v1.53.0 gopkg.in/DataDog/dd-trace-go.v1 v1.43.1 gopkg.in/fsnotify.v1 v1.4.7 @@ -329,13 +329,13 @@ require ( go.uber.org/zap v1.19.0 // indirect go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect - golang.org/x/crypto v0.5.0 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/oauth2 v0.5.0 // indirect + golang.org/x/oauth2 v0.6.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/term v0.5.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/term v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.111.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index c29771870..e0b106419 100644 --- a/go.sum +++ b/go.sum @@ -657,8 +657,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-acme/lego/v4 v4.11.0 h1:oIPoU7zBJoTfoVrbqk62+/2NsGCSgCVK1JtZSZZ28SU= -github.com/go-acme/lego/v4 v4.11.0/go.mod h1:dENL0J3/WughN2NLy0T35otK5k1EWCmXTwCw0+X5ZaE= +github.com/go-acme/lego/v4 v4.12.0 h1:jox3II6YRjt1EXvrymSQuSNgEUOcbUkF2je0kyuv6YM= +github.com/go-acme/lego/v4 v4.12.0/go.mod h1:UZoOlhVmUYP/N0z4tEbfUjoCNHRZNObzqWZtT76DIsc= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s= @@ -1958,8 +1958,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2004,8 +2004,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -2075,8 +2075,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2092,8 +2092,8 @@ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s= -golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= +golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= +golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2239,15 +2239,15 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2259,8 +2259,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2347,8 +2347,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 6977b68b72bde1522791b5167e3ff1b6e618922c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Silva?= Date: Wed, 31 May 2023 10:40:05 +0100 Subject: [PATCH 2/5] Fix multiple subsets endpoint --- .../crd/fixtures/with_multiple_subsets.yml | 54 +++++++++++++++++++ .../kubernetes/crd/kubernetes_http.go | 4 +- .../kubernetes/crd/kubernetes_test.go | 44 +++++++++++++++ 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 pkg/provider/kubernetes/crd/fixtures/with_multiple_subsets.yml diff --git a/pkg/provider/kubernetes/crd/fixtures/with_multiple_subsets.yml b/pkg/provider/kubernetes/crd/fixtures/with_multiple_subsets.yml new file mode 100644 index 000000000..4d700d7ad --- /dev/null +++ b/pkg/provider/kubernetes/crd/fixtures/with_multiple_subsets.yml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: Service +metadata: + name: whoami-svc-multiple-subsets + namespace: default + +spec: + ports: + - name: web + port: 80 + - name: web2 + port: 8080 + selector: + app: traefiklabs + task: whoami + +--- +kind: Endpoints +apiVersion: v1 +metadata: + name: whoami-svc-multiple-subsets + namespace: default + +subsets: + - addresses: + - ip: 10.10.0.1 + - ip: 10.10.0.2 + ports: + - name: web + port: 80 + - addresses: + - ip: 10.10.0.3 + - ip: 10.10.0.4 + ports: + - name: web2 + port: 8080 +--- +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: test.route + namespace: default + +spec: + entryPoints: + - foo + + routes: + - match: Host(`foo.com`) && PathPrefix(`/bar`) + kind: Rule + priority: 12 + services: + - name: whoami-svc-multiple-subsets + port: 8080 diff --git a/pkg/provider/kubernetes/crd/kubernetes_http.go b/pkg/provider/kubernetes/crd/kubernetes_http.go index d3b206301..56637a22a 100644 --- a/pkg/provider/kubernetes/crd/kubernetes_http.go +++ b/pkg/provider/kubernetes/crd/kubernetes_http.go @@ -414,8 +414,8 @@ func (c configBuilder) loadServers(parentNamespace string, svc traefikv1alpha1.L return nil, fmt.Errorf("subset not found for %s/%s", namespace, sanitizedName) } - var port int32 for _, subset := range endpoints.Subsets { + var port int32 for _, p := range subset.Ports { if svcPort.Name == p.Name { port = p.Port @@ -424,7 +424,7 @@ func (c configBuilder) loadServers(parentNamespace string, svc traefikv1alpha1.L } if port == 0 { - return nil, fmt.Errorf("cannot define a port for %s/%s", namespace, sanitizedName) + continue } protocol, err := parseServiceProtocol(svc.Scheme, svcPort.Name, svcPort.Port) diff --git a/pkg/provider/kubernetes/crd/kubernetes_test.go b/pkg/provider/kubernetes/crd/kubernetes_test.go index e5178eb37..e9620c122 100644 --- a/pkg/provider/kubernetes/crd/kubernetes_test.go +++ b/pkg/provider/kubernetes/crd/kubernetes_test.go @@ -4037,6 +4037,50 @@ func TestLoadIngressRoutes(t *testing.T) { TLS: &dynamic.TLSConfiguration{}, }, }, + { + desc: "IngressRoute, service with multiple subsets", + allowEmptyServices: true, + paths: []string{"services.yml", "with_multiple_subsets.yml"}, + expected: &dynamic.Configuration{ + UDP: &dynamic.UDPConfiguration{ + Routers: map[string]*dynamic.UDPRouter{}, + Services: map[string]*dynamic.UDPService{}, + }, + TCP: &dynamic.TCPConfiguration{ + Routers: map[string]*dynamic.TCPRouter{}, + Middlewares: map[string]*dynamic.TCPMiddleware{}, + Services: map[string]*dynamic.TCPService{}, + }, + HTTP: &dynamic.HTTPConfiguration{ + Routers: map[string]*dynamic.Router{ + "default-test-route-6b204d94623b3df4370c": { + EntryPoints: []string{"foo"}, + Service: "default-test-route-6b204d94623b3df4370c", + Rule: "Host(`foo.com`) && PathPrefix(`/bar`)", + Priority: 12, + }, + }, + Middlewares: map[string]*dynamic.Middleware{}, + Services: map[string]*dynamic.Service{ + "default-test-route-6b204d94623b3df4370c": { + LoadBalancer: &dynamic.ServersLoadBalancer{ + Servers: []dynamic.Server{ + { + URL: "http://10.10.0.3:8080", + }, + { + URL: "http://10.10.0.4:8080", + }, + }, + PassHostHeader: Bool(true), + }, + }, + }, + ServersTransports: map[string]*dynamic.ServersTransport{}, + }, + TLS: &dynamic.TLSConfiguration{}, + }, + }, { desc: "TraefikService, empty service allowed", allowEmptyServices: true, From 9aa57f362b8c8fb89ed7f4fb5e5f10fc9feba3f2 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 2 Jun 2023 11:34:06 +0200 Subject: [PATCH 3/5] fix: improve error messages related to plugins --- cmd/traefik/plugins.go | 4 ++-- pkg/plugins/client.go | 35 +++++++++++++++++++++++++---------- pkg/plugins/plugins.go | 10 +++++----- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/cmd/traefik/plugins.go b/cmd/traefik/plugins.go index f94535f92..c2b847819 100644 --- a/cmd/traefik/plugins.go +++ b/cmd/traefik/plugins.go @@ -35,12 +35,12 @@ func initPlugins(staticCfg *static.Configuration) (*plugins.Client, map[string]p var err error client, err = plugins.NewClient(opts) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, fmt.Errorf("unable to create plugins client: %w", err) } err = plugins.SetupRemotePlugins(client, staticCfg.Experimental.Plugins) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, fmt.Errorf("unable to set up plugins environment: %w", err) } plgs = staticCfg.Experimental.Plugins diff --git a/pkg/plugins/client.go b/pkg/plugins/client.go index e891da5c4..4fcdd1ab4 100644 --- a/pkg/plugins/client.go +++ b/pkg/plugins/client.go @@ -264,7 +264,7 @@ func (c *Client) unzipArchive(pName, pVersion string) error { for _, f := range archive.File { err = unzipFile(f, dest) if err != nil { - return err + return fmt.Errorf("unable to unzip %s: %w", f.Name, err) } } @@ -283,12 +283,17 @@ func unzipFile(f *zipa.File, dest string) error { p := filepath.Join(dest, pathParts[1]) if f.FileInfo().IsDir() { - return os.MkdirAll(p, f.Mode()) + err = os.MkdirAll(p, f.Mode()) + if err != nil { + return fmt.Errorf("unable to create archive directory %s: %w", p, err) + } + + return nil } err = os.MkdirAll(filepath.Dir(p), 0o750) if err != nil { - return err + return fmt.Errorf("unable to create archive directory %s for file %s: %w", filepath.Dir(p), p, err) } elt, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) @@ -347,7 +352,7 @@ func (c *Client) WriteState(plugins map[string]Descriptor) error { mp, err := json.MarshalIndent(m, "", " ") if err != nil { - return err + return fmt.Errorf("unable to marshal plugin state: %w", err) } return os.WriteFile(c.stateFile, mp, 0o600) @@ -361,10 +366,15 @@ func (c *Client) ResetAll() error { err := resetDirectory(filepath.Join(c.goPath, "..")) if err != nil { - return err + return fmt.Errorf("unable to reset plugins GoPath directory %s: %w", c.goPath, err) } - return resetDirectory(c.archives) + err = resetDirectory(c.archives) + if err != nil { + return fmt.Errorf("unable to reset plugins archives directory: %w", err) + } + + return nil } func (c *Client) buildArchivePath(pName, pVersion string) string { @@ -374,12 +384,12 @@ func (c *Client) buildArchivePath(pName, pVersion string) string { func resetDirectory(dir string) error { dirPath, err := filepath.Abs(dir) if err != nil { - return err + return fmt.Errorf("unable to get absolute path of %s: %w", dir, err) } currentPath, err := os.Getwd() if err != nil { - return err + return fmt.Errorf("unable to get the current directory: %w", err) } if strings.HasPrefix(currentPath, dirPath) { @@ -388,10 +398,15 @@ func resetDirectory(dir string) error { err = os.RemoveAll(dir) if err != nil { - return err + return fmt.Errorf("unable to remove directory %s: %w", dirPath, err) } - return os.MkdirAll(dir, 0o755) + err = os.MkdirAll(dir, 0o755) + if err != nil { + return fmt.Errorf("unable to create directory %s: %w", dirPath, err) + } + + return nil } func computeHash(filepath string) (string, error) { diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index fdfb9fbce..6888ceea4 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -21,7 +21,7 @@ func SetupRemotePlugins(client *Client, plugins map[string]Descriptor) error { err = client.CleanArchives(plugins) if err != nil { - return fmt.Errorf("failed to clean archives: %w", err) + return fmt.Errorf("unable to clean archives: %w", err) } ctx := context.Background() @@ -32,27 +32,27 @@ func SetupRemotePlugins(client *Client, plugins map[string]Descriptor) error { hash, err := client.Download(ctx, desc.ModuleName, desc.Version) if err != nil { _ = client.ResetAll() - return fmt.Errorf("failed to download plugin %s: %w", desc.ModuleName, err) + return fmt.Errorf("unable to download plugin %s: %w", desc.ModuleName, err) } err = client.Check(ctx, desc.ModuleName, desc.Version, hash) if err != nil { _ = client.ResetAll() - return fmt.Errorf("failed to check archive integrity of the plugin %s: %w", desc.ModuleName, err) + return fmt.Errorf("unable to check archive integrity of the plugin %s: %w", desc.ModuleName, err) } } err = client.WriteState(plugins) if err != nil { _ = client.ResetAll() - return fmt.Errorf("failed to write plugins state: %w", err) + return fmt.Errorf("unable to write plugins state: %w", err) } for _, desc := range plugins { err = client.Unzip(desc.ModuleName, desc.Version) if err != nil { _ = client.ResetAll() - return fmt.Errorf("failed to unzip archive: %w", err) + return fmt.Errorf("unable to unzip archive: %w", err) } } From db515195f068c304da2f967412311769b1409129 Mon Sep 17 00:00:00 2001 From: Chromo-residuum-opec Date: Sat, 3 Jun 2023 23:00:05 -0700 Subject: [PATCH 4/5] docs: fix over-indented yaml configuration of access logs --- docs/content/observability/access-logs.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/observability/access-logs.md b/docs/content/observability/access-logs.md index 8c27f5788..c8e4f1d95 100644 --- a/docs/content/observability/access-logs.md +++ b/docs/content/observability/access-logs.md @@ -154,9 +154,9 @@ accessLog: headers: defaultMode: keep names: - User-Agent: redact - Authorization: drop - Content-Type: keep + User-Agent: redact + Authorization: drop + Content-Type: keep ``` ```toml tab="File (TOML)" From c5f23493abe7bef0f080323731e171df42f29f6c Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 5 Jun 2023 10:24:06 +0200 Subject: [PATCH 5/5] chore: update linter --- .github/workflows/validate.yaml | 2 +- .golangci.yml | 12 ++++++--- integration/healthcheck_test.go | 26 +++++++++---------- pkg/middlewares/auth/basic_auth_test.go | 2 +- pkg/middlewares/auth/digest_auth_test.go | 2 +- pkg/middlewares/capture/capture_test.go | 2 +- .../redirect/redirect_scheme_test.go | 2 +- pkg/provider/file/file_test.go | 2 +- pkg/server/router/tcp/router_test.go | 2 +- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 483085825..e40e51dbb 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -7,7 +7,7 @@ on: env: GO_VERSION: '1.20' - GOLANGCI_LINT_VERSION: v1.52.2 + GOLANGCI_LINT_VERSION: v1.53.1 MISSSPELL_VERSION: v0.4.0 IN_DOCKER: "" diff --git a/.golangci.yml b/.golangci.yml index cd0093d85..ba3ce50a3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,10 +26,13 @@ linters-settings: - ^spew\.Print(f|ln)?$ - ^spew\.Dump$ depguard: - list-type: denylist - include-go-root: false - packages: - - github.com/pkg/errors + rules: + main: + deny: + - pkg: "github.com/instana/testify" + desc: not allowed + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package godox: keywords: - FIXME @@ -199,6 +202,7 @@ linters: - containedctx # too many false-positive - maintidx # kind of duplicate of gocyclo - nonamedreturns # Too strict + - gosmopolitan # not relevant issues: exclude-use-default: false diff --git a/integration/healthcheck_test.go b/integration/healthcheck_test.go index 128a447e8..c6ab99809 100644 --- a/integration/healthcheck_test.go +++ b/integration/healthcheck_test.go @@ -61,7 +61,7 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) { client := &http.Client{} whoamiHosts := []string{s.whoami1IP, s.whoami2IP} for _, whoami := range whoamiHosts { - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -72,7 +72,7 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) { c.Assert(err, checker.IsNil) // Change one whoami health to 200 - statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200"))) + statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusOKReq1) c.Assert(err, checker.IsNil) @@ -138,7 +138,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) { client := &http.Client{} whoamiHosts := []string{s.whoami1IP, s.whoami2IP} for _, whoami := range whoamiHosts { - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -149,7 +149,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) { c.Assert(err, checker.IsNil) // reactivate the whoami2 - statusInternalServerOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBuffer([]byte("200"))) + statusInternalServerOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerOkReq) c.Assert(err, checker.IsNil) @@ -174,7 +174,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) { func (s *HealthCheckSuite) TestPortOverload(c *check.C) { // Set one whoami health to 200 client := &http.Client{} - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -203,7 +203,7 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) { c.Assert(err, checker.IsNil) // Set one whoami health to 500 - statusInternalServerErrorReq, err = http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err = http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -232,7 +232,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) { // Set whoami health to 200 to be sure to start with the wanted status client := &http.Client{} - statusOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200"))) + statusOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusOkReq) c.Assert(err, checker.IsNil) @@ -253,7 +253,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) { c.Assert(err, checker.IsNil) // Set whoami health to 500 - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -266,7 +266,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) { c.Assert(err, checker.IsNil) // Change one whoami health to 200 - statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200"))) + statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusOKReq1) c.Assert(err, checker.IsNil) @@ -312,7 +312,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) { whoamiHosts := []string{s.whoami1IP, s.whoami3IP} for _, whoami := range whoamiHosts { - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -394,7 +394,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) { // Bring whoami2 and whoami4 down whoamiHosts = []string{s.whoami2IP, s.whoami4IP} for _, whoami := range whoamiHosts { - statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500"))) + statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusInternalServerErrorReq) c.Assert(err, checker.IsNil) @@ -420,7 +420,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) { // Bring everything back up. whoamiHosts = []string{s.whoami1IP, s.whoami2IP, s.whoami3IP, s.whoami4IP} for _, whoami := range whoamiHosts { - statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("200"))) + statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("200")) c.Assert(err, checker.IsNil) _, err = client.Do(statusOKReq) c.Assert(err, checker.IsNil) @@ -585,7 +585,7 @@ func (s *HealthCheckSuite) TestPropagateReload(c *check.C) { client := http.Client{ Timeout: 10 * time.Second, } - statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBuffer([]byte("500"))) + statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBufferString("500")) c.Assert(err, checker.IsNil) _, err = client.Do(statusOKReq) c.Assert(err, checker.IsNil) diff --git a/pkg/middlewares/auth/basic_auth_test.go b/pkg/middlewares/auth/basic_auth_test.go index 9e1b92ad1..893443b96 100644 --- a/pkg/middlewares/auth/basic_auth_test.go +++ b/pkg/middlewares/auth/basic_auth_test.go @@ -218,7 +218,7 @@ func TestBasicAuthUsersFromFile(t *testing.T) { usersFile, err := os.CreateTemp(t.TempDir(), "auth-users") require.NoError(t, err) - _, err = usersFile.Write([]byte(test.userFileContent)) + _, err = usersFile.WriteString(test.userFileContent) require.NoError(t, err) // Creates the configuration for our Authenticator diff --git a/pkg/middlewares/auth/digest_auth_test.go b/pkg/middlewares/auth/digest_auth_test.go index 066f80e0f..a972223b4 100644 --- a/pkg/middlewares/auth/digest_auth_test.go +++ b/pkg/middlewares/auth/digest_auth_test.go @@ -96,7 +96,7 @@ func TestDigestAuthUsersFromFile(t *testing.T) { usersFile, err := os.CreateTemp(t.TempDir(), "auth-users") require.NoError(t, err) - _, err = usersFile.Write([]byte(test.userFileContent)) + _, err = usersFile.WriteString(test.userFileContent) require.NoError(t, err) // Creates the configuration for our Authenticator diff --git a/pkg/middlewares/capture/capture_test.go b/pkg/middlewares/capture/capture_test.go index 9d8f91fcf..f8652e423 100644 --- a/pkg/middlewares/capture/capture_test.go +++ b/pkg/middlewares/capture/capture_test.go @@ -177,7 +177,7 @@ func generateBytes(length int) []byte { } func TestRequestReader(t *testing.T) { - buff := bytes.NewBuffer([]byte("foo")) + buff := bytes.NewBufferString("foo") rr := readCounter{source: io.NopCloser(buff)} assert.Equal(t, int64(0), rr.size) diff --git a/pkg/middlewares/redirect/redirect_scheme_test.go b/pkg/middlewares/redirect/redirect_scheme_test.go index 07ae54246..8de531a2c 100644 --- a/pkg/middlewares/redirect/redirect_scheme_test.go +++ b/pkg/middlewares/redirect/redirect_scheme_test.go @@ -333,7 +333,7 @@ func TestRedirectSchemeHandler(t *testing.T) { schemeRegex := `^(https?):\/\/(\[[\w:.]+\]|[\w\._-]+)?(:\d+)?(.*)$` re, _ := regexp.Compile(schemeRegex) - if re.Match([]byte(test.url)) { + if re.MatchString(test.url) { match := re.FindStringSubmatch(test.url) req.RequestURI = match[4] diff --git a/pkg/provider/file/file_test.go b/pkg/provider/file/file_test.go index 76fb49282..20d74d2d9 100644 --- a/pkg/provider/file/file_test.go +++ b/pkg/provider/file/file_test.go @@ -56,7 +56,7 @@ func TestTLSCertificateContent(t *testing.T) { keyFile = "` + fileTLSKey.Name() + `" ` - _, err = fileConfig.Write([]byte(content)) + _, err = fileConfig.WriteString(content) require.NoError(t, err) provider := &Provider{} diff --git a/pkg/server/router/tcp/router_test.go b/pkg/server/router/tcp/router_test.go index 26e799837..64753a0ea 100644 --- a/pkg/server/router/tcp/router_test.go +++ b/pkg/server/router/tcp/router_test.go @@ -840,7 +840,7 @@ func checkTCPTLS(addr string, timeout time.Duration, tlsVersion uint16) (err err err = conn.SetReadDeadline(time.Now().Add(timeout)) if err != nil { - return + return err } var buf bytes.Buffer