Skip to content

Commit 4ac09e8

Browse files
authored
Merge pull request #3184 from cupakob/remove-redundant-type-conversion
🌱 Remove redundant type conversion
2 parents 7e8eecc + d9f0199 commit 4ac09e8

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

pkg/logging/constants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ func From(obj Object) []interface{} {
8484
func FromPrefix(prefix string, obj Object) []interface{} {
8585
gvk := obj.GetObjectKind().GroupVersionKind()
8686
return []interface{}{
87-
prefix + "." + string(WorkspaceKey),
87+
prefix + "." + WorkspaceKey,
8888
logicalcluster.From(obj).String(),
89-
prefix + "." + string(NamespaceKey),
89+
prefix + "." + NamespaceKey,
9090
obj.GetNamespace(),
91-
prefix + "." + string(NameKey),
91+
prefix + "." + NameKey,
9292
obj.GetName(),
93-
prefix + "." + string(APIVersionKey),
93+
prefix + "." + APIVersionKey,
9494
gvk.GroupVersion(),
9595
}
9696
}

pkg/proxy/options/authentication.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/spf13/pflag"
2828

2929
"k8s.io/apimachinery/pkg/util/sets"
30-
"k8s.io/apiserver/pkg/authentication/authenticator"
3130
"k8s.io/apiserver/pkg/authentication/user"
3231
genericapiserver "k8s.io/apiserver/pkg/server"
3332
"k8s.io/client-go/rest"
@@ -106,7 +105,7 @@ func (c *Authentication) ApplyTo(ctx context.Context, authenticationInfo *generi
106105
if c.serviceAccountAuthEnabled() {
107106
authenticationInfo.APIAudiences = c.BuiltInOptions.APIAudiences
108107
if len(c.BuiltInOptions.ServiceAccounts.Issuers) != 0 && len(c.BuiltInOptions.APIAudiences) == 0 {
109-
authenticationInfo.APIAudiences = authenticator.Audiences(c.BuiltInOptions.ServiceAccounts.Issuers)
108+
authenticationInfo.APIAudiences = c.BuiltInOptions.ServiceAccounts.Issuers
110109
}
111110

112111
config := rest.CopyConfig(rootShardConfig)

pkg/server/filters/filters.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ func init() {
7676
// WithAuditEventClusterAnnotation adds the cluster name into the annotation of an audit
7777
// event. Needs initialized annotations.
7878
func WithAuditEventClusterAnnotation(handler http.Handler) http.HandlerFunc {
79-
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
79+
return func(w http.ResponseWriter, req *http.Request) {
8080
cluster := request.ClusterFrom(req.Context())
8181
if cluster != nil {
8282
kaudit.AddAuditAnnotation(req.Context(), workspaceAnnotation, cluster.Name.String())
8383
}
8484

8585
handler.ServeHTTP(w, req)
86-
})
86+
}
8787
}
8888

8989
// WithBlockInactiveLogicalClusters ensures that any requests to logical
@@ -94,7 +94,7 @@ func WithBlockInactiveLogicalClusters(handler http.Handler, kcpClusterClient inf
9494
"/apis/core.kcp.io/v1alpha1/logicalclusters",
9595
}
9696

97-
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
97+
return func(w http.ResponseWriter, req *http.Request) {
9898
_, newURL, _, err := ClusterPathFromAndStrip(req)
9999
if err != nil {
100100
responsewriters.InternalError(w, req, err)
@@ -126,7 +126,7 @@ func WithBlockInactiveLogicalClusters(handler http.Handler, kcpClusterClient inf
126126
}
127127

128128
handler.ServeHTTP(w, req)
129-
})
129+
}
130130
}
131131

132132
// WithClusterScope reads a cluster name from the URL path and puts it into the context.

pkg/virtual/apiexport/authorizer/content_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestContentAuthorizer(t *testing.T) {
6161
}),
6262
}
6363

64-
ctx := dynamiccontext.WithAPIDomainKey(context.Background(), dynamiccontext.APIDomainKey("foo/bar"))
64+
ctx := dynamiccontext.WithAPIDomainKey(context.Background(), "foo/bar")
6565
dec, _, err := auth.Authorize(ctx, &authorizer.AttributesRecord{
6666
User: &user.DefaultInfo{},
6767
})

pkg/virtual/initializingworkspaces/builder/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ func digestUrl(urlPath, rootPathPrefix string) (
322322
// Where the withoutRootPathPrefix starts here: ┘
323323
parts := strings.SplitN(withoutRootPathPrefix, "/", 2)
324324
if len(parts) < 2 {
325-
return genericapirequest.Cluster{}, dynamiccontext.APIDomainKey(""), "", false
325+
return genericapirequest.Cluster{}, "", "", false
326326
}
327327

328328
initializerName := parts[0]
329329
if initializerName == "" {
330-
return genericapirequest.Cluster{}, dynamiccontext.APIDomainKey(""), "", false
330+
return genericapirequest.Cluster{}, "", "", false
331331
}
332332

333333
realPath := "/" + parts[1]
@@ -337,7 +337,7 @@ func digestUrl(urlPath, rootPathPrefix string) (
337337
// We are now here: ┘
338338
// Now, we parse out the logical cluster.
339339
if !strings.HasPrefix(realPath, "/clusters/") {
340-
return genericapirequest.Cluster{}, dynamiccontext.APIDomainKey(""), "", false // don't accept
340+
return genericapirequest.Cluster{}, "", "", false // don't accept
341341
}
342342

343343
withoutClustersPrefix := strings.TrimPrefix(realPath, "/clusters/")

0 commit comments

Comments
 (0)