Skip to content

Commit 7c3ffec

Browse files
deads2kironcladlou
authored andcommitted
UPSTREAM: 51932: fix format of forbidden messages
:100644 100644 5c6c9bf756... df90ccf6a8... M staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go
1 parent 9619cd1 commit 7c3ffec

File tree

1 file changed

+5
-5
lines changed
  • staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters

1 file changed

+5
-5
lines changed

staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ func Forbidden(attributes authorizer.Attributes, w http.ResponseWriter, req *htt
4444
w.WriteHeader(http.StatusForbidden)
4545

4646
if len(reason) == 0 {
47-
fmt.Fprintf(w, "%s", msg)
47+
fmt.Fprintf(w, "%s.", msg)
4848
} else {
49-
fmt.Fprintf(w, "%s: %q", msg, reason)
49+
fmt.Fprintf(w, "%s: %s", msg, reason)
5050
}
5151
}
5252

@@ -57,7 +57,7 @@ func forbiddenMessage(attributes authorizer.Attributes) string {
5757
}
5858

5959
if !attributes.IsResourceRequest() {
60-
return fmt.Sprintf("User %q cannot %s path %q.", username, attributes.GetVerb(), attributes.GetPath())
60+
return fmt.Sprintf("User %q cannot %s path %q", username, attributes.GetVerb(), attributes.GetPath())
6161
}
6262

6363
resource := attributes.GetResource()
@@ -69,10 +69,10 @@ func forbiddenMessage(attributes authorizer.Attributes) string {
6969
}
7070

7171
if ns := attributes.GetNamespace(); len(ns) > 0 {
72-
return fmt.Sprintf("User %q cannot %s %s in the namespace %q.", username, attributes.GetVerb(), resource, ns)
72+
return fmt.Sprintf("User %q cannot %s %s in the namespace %q", username, attributes.GetVerb(), resource, ns)
7373
}
7474

75-
return fmt.Sprintf("User %q cannot %s %s at the cluster scope.", username, attributes.GetVerb(), resource)
75+
return fmt.Sprintf("User %q cannot %s %s at the cluster scope", username, attributes.GetVerb(), resource)
7676
}
7777

7878
// InternalError renders a simple internal error

0 commit comments

Comments
 (0)