From 4a34cec9143abe83dbce1b0399913b048d96bf0f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 10 Aug 2021 16:09:19 -0700 Subject: [PATCH] Add server version to websocket pings --- pkg/resources/schema.go | 4 ++-- pkg/server/server.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/resources/schema.go b/pkg/resources/schema.go index 61a08ce..ff3fee1 100644 --- a/pkg/resources/schema.go +++ b/pkg/resources/schema.go @@ -24,7 +24,7 @@ import ( ) func DefaultSchemas(ctx context.Context, baseSchema *types.APISchemas, ccache clustercache.ClusterCache, - cg proxy.ClientGetter, schemaFactory steveschema.Factory) error { + cg proxy.ClientGetter, schemaFactory steveschema.Factory, serverVersion string) error { counts.Register(baseSchema, ccache) subscribe.Register(baseSchema, func(apiOp *types.APIRequest) *types.APISchemas { user, ok := request.UserFrom(apiOp.Context()) @@ -35,7 +35,7 @@ func DefaultSchemas(ctx context.Context, baseSchema *types.APISchemas, ccache cl } } return apiOp.Schemas - }) + }, serverVersion) apiroot.Register(baseSchema, []string{"v1"}, "proxy:/apis") cluster.Register(ctx, baseSchema, cg, schemaFactory) userpreferences.Register(baseSchema) diff --git a/pkg/server/server.go b/pkg/server/server.go index e8615d8..1a54a9f 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -37,6 +37,7 @@ type Server struct { AccessSetLookup accesscontrol.AccessSetLookup APIServer *apiserver.Server ClusterRegistry string + Version string authMiddleware auth.Middleware controllers *Controllers @@ -59,6 +60,7 @@ type Options struct { AggregationSecretNamespace string AggregationSecretName string ClusterRegistry string + ServerVersion string } func New(ctx context.Context, restConfig *rest.Config, opts *Options) (*Server, error) { @@ -77,6 +79,7 @@ func New(ctx context.Context, restConfig *rest.Config, opts *Options) (*Server, aggregationSecretNamespace: opts.AggregationSecretNamespace, aggregationSecretName: opts.AggregationSecretName, ClusterRegistry: opts.ClusterRegistry, + Version: opts.ServerVersion, } if err := setup(ctx, server); err != nil { @@ -135,7 +138,7 @@ func setup(ctx context.Context, server *Server) error { server.ClusterCache = ccache sf := schema.NewCollection(ctx, server.BaseSchemas, asl) - if err = resources.DefaultSchemas(ctx, server.BaseSchemas, ccache, server.ClientFactory, sf); err != nil { + if err = resources.DefaultSchemas(ctx, server.BaseSchemas, ccache, server.ClientFactory, sf, server.Version); err != nil { return err }