mirror of https://github.com/k3s-io/k3s
Merge pull request #35034 from sttts/sttts-remove-srvrunoption-apigroupprefix
Automatic merge from submit-queue Make APIGroupPrefix constant: "/apis" It's not wired externally, so let's get rid of it and make it constant.pull/6/head
commit
06c0416de4
|
@ -65,7 +65,7 @@ func installCoreAPIs(s *options.ServerRunOptions, g *genericapiserver.GenericAPI
|
|||
ParameterCodec: core.ParameterCodec,
|
||||
NegotiatedSerializer: core.Codecs,
|
||||
}
|
||||
if err := g.InstallLegacyAPIGroup(genericapiserver.LegacyAPIPrefix, &apiGroupInfo); err != nil {
|
||||
if err := g.InstallLegacyAPIGroup(genericapiserver.DefaultLegacyAPIPrefix, &apiGroupInfo); err != nil {
|
||||
glog.Fatalf("Error in registering group version: %+v.\n Error: %v\n", apiGroupInfo, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// LegacyAPIPrefix is where the the legacy APIs will be located
|
||||
LegacyAPIPrefix = "/api"
|
||||
// DefaultLegacyAPIPrefix is where the the legacy APIs will be located.
|
||||
DefaultLegacyAPIPrefix = "/api"
|
||||
|
||||
// APIGroupPrefix is where non-legacy API group will be located.
|
||||
APIGroupPrefix = "/apis"
|
||||
)
|
||||
|
||||
// Config is a structure used to configure a GenericAPIServer.
|
||||
|
@ -206,7 +209,7 @@ func NewConfig() *Config {
|
|||
ServiceReadWritePort: 443,
|
||||
RequestContextMapper: api.NewRequestContextMapper(),
|
||||
BuildHandlerChainsFunc: DefaultBuildHandlerChain,
|
||||
LegacyAPIGroupPrefixes: sets.NewString(LegacyAPIPrefix),
|
||||
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
|
||||
|
||||
EnableIndex: true,
|
||||
EnableSwaggerSupport: true,
|
||||
|
@ -275,7 +278,6 @@ func (c *Config) ApplyOptions(options *options.ServerRunOptions) *Config {
|
|||
c.InsecureServingInfo = insecureServingInfo
|
||||
}
|
||||
|
||||
c.APIGroupPrefix = options.APIGroupPrefix
|
||||
c.CorsAllowedOriginList = options.CorsAllowedOriginList
|
||||
c.EnableGarbageCollection = options.EnableGarbageCollection
|
||||
c.EnableProfiling = options.EnableProfiling
|
||||
|
@ -373,7 +375,6 @@ func (c completedConfig) New() (*GenericAPIServer, error) {
|
|||
s := &GenericAPIServer{
|
||||
ServiceClusterIPRange: c.ServiceClusterIPRange,
|
||||
LoopbackClientConfig: c.LoopbackClientConfig,
|
||||
apiPrefix: c.APIGroupPrefix,
|
||||
legacyAPIGroupPrefixes: c.LegacyAPIGroupPrefixes,
|
||||
admissionControl: c.AdmissionControl,
|
||||
requestContextMapper: c.RequestContextMapper,
|
||||
|
@ -522,8 +523,8 @@ func DefaultAndValidateRunOptions(options *options.ServerRunOptions) {
|
|||
}
|
||||
|
||||
func NewRequestInfoResolver(c *Config) *request.RequestInfoFactory {
|
||||
apiPrefixes := sets.NewString(strings.Trim(c.APIGroupPrefix, "/")) // all possible API prefixes
|
||||
legacyAPIPrefixes := sets.String{} // APIPrefixes that won't have groups (legacy)
|
||||
apiPrefixes := sets.NewString(strings.Trim(APIGroupPrefix, "/")) // all possible API prefixes
|
||||
legacyAPIPrefixes := sets.String{} // APIPrefixes that won't have groups (legacy)
|
||||
for legacyAPIPrefix := range c.LegacyAPIGroupPrefixes {
|
||||
apiPrefixes.Insert(strings.Trim(legacyAPIPrefix, "/"))
|
||||
legacyAPIPrefixes.Insert(strings.Trim(legacyAPIPrefix, "/"))
|
||||
|
|
|
@ -101,9 +101,6 @@ type GenericAPIServer struct {
|
|||
// TODO eventually we should be able to factor this out to take place during initialization.
|
||||
enableSwaggerSupport bool
|
||||
|
||||
// apiPrefix is the prefix where API groups live, usually /apis
|
||||
apiPrefix string
|
||||
|
||||
// legacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
|
||||
// to InstallLegacyAPIGroup
|
||||
legacyAPIGroupPrefixes sets.String
|
||||
|
@ -331,7 +328,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
|
|||
return fmt.Errorf("cannot register handler with an empty version for %#v", *apiGroupInfo)
|
||||
}
|
||||
|
||||
if err := s.installAPIResources(s.apiPrefix, apiGroupInfo); err != nil {
|
||||
if err := s.installAPIResources(APIGroupPrefix, apiGroupInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -360,7 +357,7 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
|
|||
}
|
||||
|
||||
s.AddAPIGroupForDiscovery(apiGroup)
|
||||
s.HandlerContainer.Add(apiserver.NewGroupWebService(s.Serializer, s.apiPrefix+"/"+apiGroup.Name, apiGroup))
|
||||
s.HandlerContainer.Add(apiserver.NewGroupWebService(s.Serializer, APIGroupPrefix+"/"+apiGroup.Name, apiGroup))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -487,7 +484,7 @@ func (s *GenericAPIServer) InstallOpenAPI() {
|
|||
// DynamicApisDiscovery returns a webservice serving api group discovery.
|
||||
// Note: during the server runtime apiGroupsForDiscovery might change.
|
||||
func (s *GenericAPIServer) DynamicApisDiscovery() *restful.WebService {
|
||||
return apiserver.NewApisWebService(s.Serializer, s.apiPrefix, func(req *restful.Request) []unversioned.APIGroup {
|
||||
return apiserver.NewApisWebService(s.Serializer, APIGroupPrefix, func(req *restful.Request) []unversioned.APIGroup {
|
||||
s.apiGroupsForDiscoveryLock.RLock()
|
||||
defer s.apiGroupsForDiscoveryLock.RUnlock()
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
|
|||
config.ProxyDialer = func(network, addr string) (net.Conn, error) { return nil, nil }
|
||||
config.ProxyTLSClientConfig = &tls.Config{}
|
||||
config.LegacyAPIGroupPrefixes = sets.NewString("/api")
|
||||
config.APIGroupPrefix = "/apis"
|
||||
|
||||
return etcdServer, *config, assert.New(t)
|
||||
}
|
||||
|
@ -81,7 +80,6 @@ func TestNew(t *testing.T) {
|
|||
// Verify many of the variables match their config counterparts
|
||||
assert.Equal(s.enableSwaggerSupport, config.EnableSwaggerSupport)
|
||||
assert.Equal(s.legacyAPIGroupPrefixes, config.LegacyAPIGroupPrefixes)
|
||||
assert.Equal(s.apiPrefix, config.APIGroupPrefix)
|
||||
assert.Equal(s.admissionControl, config.AdmissionControl)
|
||||
assert.Equal(s.RequestContextMapper(), config.RequestContextMapper)
|
||||
|
||||
|
@ -106,7 +104,6 @@ func TestInstallAPIGroups(t *testing.T) {
|
|||
defer etcdserver.Terminate(t)
|
||||
|
||||
config.LegacyAPIGroupPrefixes = sets.NewString("/apiPrefix")
|
||||
config.APIGroupPrefix = "/apiGroupPrefix"
|
||||
|
||||
s, err := config.SkipComplete().New()
|
||||
if err != nil {
|
||||
|
@ -145,9 +142,9 @@ func TestInstallAPIGroups(t *testing.T) {
|
|||
// "/api/v1"
|
||||
config.LegacyAPIGroupPrefixes.List()[0] + "/" + apiGroupMeta.GroupVersion.Version,
|
||||
// "/apis/extensions"
|
||||
config.APIGroupPrefix + "/" + extensionsGroupMeta.GroupVersion.Group,
|
||||
APIGroupPrefix + "/" + extensionsGroupMeta.GroupVersion.Group,
|
||||
// "/apis/extensions/v1beta1"
|
||||
config.APIGroupPrefix + "/" + extensionsGroupMeta.GroupVersion.String(),
|
||||
APIGroupPrefix + "/" + extensionsGroupMeta.GroupVersion.String(),
|
||||
}
|
||||
for _, path := range validPaths {
|
||||
_, err := http.Get(server.URL + path)
|
||||
|
@ -224,7 +221,6 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
|
|||
authz := mockAuthorizer{}
|
||||
|
||||
config.LegacyAPIGroupPrefixes = sets.NewString("/apiPrefix")
|
||||
config.APIGroupPrefix = "/apiGroupPrefix"
|
||||
config.Authorizer = &authz
|
||||
|
||||
config.EnableSwaggerUI = true
|
||||
|
|
|
@ -55,7 +55,6 @@ var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABA
|
|||
|
||||
// ServerRunOptions contains the options while running a generic api server.
|
||||
type ServerRunOptions struct {
|
||||
APIGroupPrefix string
|
||||
AdmissionControl string
|
||||
AdmissionControlConfigFile string
|
||||
AdvertiseAddress net.IP
|
||||
|
@ -123,7 +122,6 @@ type ServerRunOptions struct {
|
|||
|
||||
func NewServerRunOptions() *ServerRunOptions {
|
||||
return &ServerRunOptions{
|
||||
APIGroupPrefix: "/apis",
|
||||
AdmissionControl: "AlwaysAdmit",
|
||||
AnonymousAuth: true,
|
||||
AuthorizationMode: "AlwaysAllow",
|
||||
|
|
|
@ -265,7 +265,7 @@ func (m *Master) InstallLegacyAPI(c *Config, restOptionsGetter genericapiserver.
|
|||
}
|
||||
}
|
||||
|
||||
if err := m.GenericAPIServer.InstallLegacyAPIGroup(genericapiserver.LegacyAPIPrefix, &apiGroupInfo); err != nil {
|
||||
if err := m.GenericAPIServer.InstallLegacyAPIGroup(genericapiserver.DefaultLegacyAPIPrefix, &apiGroupInfo); err != nil {
|
||||
glog.Fatalf("Error in registering group versions: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ func setUp(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *assert.
|
|||
config.GenericConfig.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
||||
config.GenericConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||
config.GenericConfig.LegacyAPIGroupPrefixes = sets.NewString("/api")
|
||||
config.GenericConfig.APIGroupPrefix = "/apis"
|
||||
config.GenericConfig.APIResourceConfigSource = DefaultAPIResourceConfigSource()
|
||||
config.GenericConfig.ProxyDialer = func(network, addr string) (net.Conn, error) { return nil, nil }
|
||||
config.GenericConfig.ProxyTLSClientConfig = &tls.Config{}
|
||||
|
|
Loading…
Reference in New Issue