Skip to content

Commit

Permalink
Use existing OpenAPIV3Config functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidswiss committed Jul 9, 2024
1 parent 8cd3ef1 commit 62c720c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module sigs.k8s.io/apiserver-runtime

go 1.22.0

toolchain go1.22.5

require (
github.com/golangci/golangci-lint v1.50.1
github.com/google/gofuzz v1.2.0
Expand Down
4 changes: 4 additions & 0 deletions internal/sample-apiserver/pkg/cmd/server/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func SetOpenAPIDefinitions(name, version string, defs openapicommon.GetOpenAPIDe
config.OpenAPIConfig = pkgserver.DefaultOpenAPIConfig(defs, openapi.NewDefinitionNamer(apiserver.Scheme))
config.OpenAPIConfig.Info.Title = name
config.OpenAPIConfig.Info.Version = version

config.OpenAPIV3Config = pkgserver.DefaultOpenAPIV3Config(defs, openapi.NewDefinitionNamer(apiserver.Scheme))
config.OpenAPIV3Config.Info.Title = name
config.OpenAPIV3Config.Info.Version = version
return config
})
}
Expand Down
14 changes: 6 additions & 8 deletions internal/sample-apiserver/pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import (
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime/schema"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
utilfeature "k8s.io/apiserver/pkg/util/feature"
sampleopenapi "k8s.io/sample-apiserver/pkg/generated/openapi"
"sigs.k8s.io/apiserver-runtime/internal/sample-apiserver/pkg/apiserver"
)

Expand Down Expand Up @@ -139,13 +137,13 @@ func (o *WardleServerOptions) Config() (*apiserver.Config, error) {
// change: apiserver-runtime
// OpenAPIConfig set through ApplyRecommendedConfigFns by calling SetOpenAPIDefinitions
//
serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIConfig.Info.Title = "Wardle"
serverConfig.OpenAPIConfig.Info.Version = "0.1"
// serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme))
// serverConfig.OpenAPIConfig.Info.Title = "Wardle"
// serverConfig.OpenAPIConfig.Info.Version = "0.1"

serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIV3Config.Info.Title = "Wardle"
serverConfig.OpenAPIV3Config.Info.Version = "0.1"
// serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme))
// serverConfig.OpenAPIV3Config.Info.Title = "Wardle"
// serverConfig.OpenAPIV3Config.Info.Version = "0.1"

if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil {
return nil, err
Expand Down

0 comments on commit 62c720c

Please sign in to comment.