Skip to content

Commit 78b4035

Browse files
author
Flynn
committed
Upgrade k8s.io/kube-openapi to fix support for rewrite: ""
This turned out to be an upstream bug in k8s.io/kube-openapi. Upgrading that package fixes the bug. kubernetes/kube-openapi#230 Signed-off-by: Flynn <[email protected]> Signed-off-by: Luke Shumaker <[email protected]>
1 parent 5f06035 commit 78b4035

File tree

8 files changed

+61
-4
lines changed

8 files changed

+61
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Please see the [Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest
8989
`Mappings` that set `spec.cors.origins` to a string rather than a list of strings; this has been
9090
fixed, and these `Mappings` should once again function correctly.
9191

92+
- Bugfix: Using `rewrite: ""` in a `Mapping` is correctly handled to mean "do not rewrite the path
93+
at all".
94+
9295
## 2.1.1 not issued
9396

9497
*Emissary-ingress 2.1.1 was not issued; Ambassador Edge Stack 2.1.1 uses Emissary-ingress 2.1.0.*

OPENSOURCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ following Free and Open Source software:
111111
k8s.io/component-base v0.20.2 Apache License 2.0
112112
k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027 Apache License 2.0
113113
k8s.io/klog/v2 v2.10.0 Apache License 2.0
114-
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd Apache License 2.0
114+
k8s.io/kube-openapi v0.0.0-20210304212320-e467f52fd9db Apache License 2.0
115115
k8s.io/kubectl v0.20.2 Apache License 2.0
116116
k8s.io/kubernetes v1.20.2 Apache License 2.0
117117
k8s.io/metrics v0.20.2 Apache License 2.0

docs/releaseNotes.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ items:
4343
<code>spec.cors.origins</code> to a string rather than a list of strings; this has been
4444
fixed, and these <code>Mappings<code> should once again function correctly.
4545
46+
- title: Correctly handle empty rewrite in a Mapping
47+
type: bugfix
48+
body: >-
49+
Using <code>rewrite: ""</code> in a <code>Mapping</code> is correctly handled
50+
to mean "do not rewrite the path at all".
51+
docs: topics/using/rewrites
52+
4653
- version: 2.1.1
4754
date: 'N/A'
4855
notes:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ require (
8989
k8s.io/client-go v0.20.2
9090
k8s.io/code-generator v0.20.2
9191
k8s.io/klog/v2 v2.10.0
92-
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
92+
k8s.io/kube-openapi v0.0.0-20210304212320-e467f52fd9db
9393
k8s.io/kubectl v0.20.2
9494
k8s.io/kubernetes v1.20.2
9595
k8s.io/metrics v0.20.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,8 @@ k8s.io/kube-controller-manager v0.20.2/go.mod h1:tEuBoNyKDqoHClDyLePZCs38XuVv5jC
11151115
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
11161116
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd h1:sOHNzJIkytDF6qadMNKhhDRpc6ODik8lVC6nOur7B2c=
11171117
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM=
1118+
k8s.io/kube-openapi v0.0.0-20210304212320-e467f52fd9db h1:6eSQzsKNEqxmpqbul2YVDt5O4MPA+Q6RljtpWb536bE=
1119+
k8s.io/kube-openapi v0.0.0-20210304212320-e467f52fd9db/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE=
11181120
k8s.io/kube-proxy v0.20.2/go.mod h1:l75PYLoA+hI6WAfT/2cFPUcWy8XWMFGvsyw8UXCNuJc=
11191121
k8s.io/kube-scheduler v0.20.2/go.mod h1:H21kpnQN7U3jRz/MwMxdGPC66UBuTibbq5LEy5AztBg=
11201122
k8s.io/kubectl v0.20.2 h1:mXExF6N4eQUYmlfXJmfWIheCBLF6/n4VnwQKbQki5iE=
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package getambassadorio_test
2+
3+
import (
4+
"encoding/json"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
9+
getambassadorio "github.com/datawire/ambassador/v2/pkg/api/getambassador.io"
10+
"github.com/datawire/ambassador/v2/pkg/kates"
11+
"github.com/datawire/dlib/dlog"
12+
)
13+
14+
func TestValidation(t *testing.T) {
15+
jsonStr := `{
16+
"apiVersion":"getambassador.io/v2",
17+
"kind":"Mapping",
18+
"metadata":{
19+
"annotations":{
20+
"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"getambassador.io/v3alpha1\",\"kind\":\"Mapping\",\"metadata\":{\"annotations\":{},\"name\":\"quote-rewrite\",\"namespace\":\"default\"},\"spec\":{\"hostname\":\"*\",\"prefix\":\"/ffs/\",\"rewrite\":\"\",\"service\":\"quote\"}}"
21+
},
22+
"creationTimestamp":"2022-01-19T00:11:43Z",
23+
"generation":1,
24+
"name":"quote-rewrite",
25+
"namespace":"default",
26+
"uid":"01b3ddea-24d7-45c6-a05a-64386f1b9588"
27+
},
28+
"spec":{
29+
"ambassador_id":[
30+
"--apiVersion-v3alpha1-only--default"
31+
],
32+
"prefix":"/ffs/",
33+
"rewrite":"",
34+
"service":"quote"
35+
}
36+
}`
37+
38+
var obj kates.Unstructured
39+
require.NoError(t, json.Unmarshal([]byte(jsonStr), &obj.Object))
40+
41+
validator := getambassadorio.NewValidator()
42+
ctx := dlog.NewTestContext(t, true)
43+
44+
require.NoError(t, validator.Validate(ctx, &obj))
45+
}

vendor/k8s.io/kube-openapi/pkg/validation/validate/type.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ k8s.io/gengo/types
814814
# k8s.io/klog/v2 v2.10.0
815815
## explicit; go 1.13
816816
k8s.io/klog/v2
817-
# k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
817+
# k8s.io/kube-openapi v0.0.0-20210304212320-e467f52fd9db
818818
## explicit; go 1.12
819819
k8s.io/kube-openapi/pkg/common
820820
k8s.io/kube-openapi/pkg/util/proto

0 commit comments

Comments
 (0)