Skip to content

Commit d57c237

Browse files
xrstfgman0
authored andcommitted
UPSTREAM: <squash>: prevent conflict with pre-existing auth annotation
On-behalf-of: @SAP [email protected]
1 parent fe0acf7 commit d57c237

File tree

1 file changed

+5
-3
lines changed
  • staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook

1 file changed

+5
-3
lines changed

staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ import (
5555
const (
5656
// The maximum length of requester-controlled attributes to allow caching.
5757
maxControlledAttrCacheSize = 10000
58+
59+
// ClusterNameKey is the logical cluster name a webhook message originates from.
60+
ClusterNameKey = "authorization.kubernetes.io/cluster-name"
5861
)
5962

6063
// DefaultRetryBackoff returns the default backoff parameters for webhook retry.
@@ -197,12 +200,11 @@ func (w *WebhookAuthorizer) Authorize(ctx context.Context, attr authorizer.Attri
197200
}
198201
}
199202

200-
clusterName, err := request.ClusterNameFrom(ctx)
201-
if err == nil {
203+
if clusterName, err := request.ClusterNameFrom(ctx); err == nil {
202204
if r.Spec.Extra == nil {
203205
r.Spec.Extra = map[string]authorizationv1.ExtraValue{}
204206
}
205-
r.Spec.Extra["authentication.kubernetes.io/cluster-name"] = authorizationv1.ExtraValue{clusterName.Path().String()}
207+
r.Spec.Extra[ClusterNameKey] = authorizationv1.ExtraValue{clusterName.Path().String()}
206208
}
207209

208210
if attr.IsResourceRequest() {

0 commit comments

Comments
 (0)