Make master index optional when master is used in other contexts

OpenShift provides a default URL at the root that shows the UI. The
provided flag makes loading the index handler optional for now.
This commit is contained in:
Clayton Coleman
2015-01-30 18:53:04 -05:00
parent 964080283a
commit 42175b433a
4 changed files with 29 additions and 12 deletions

View File

@@ -65,17 +65,21 @@ import (
// Config is a structure used to configure a Master.
type Config struct {
Client *client.Client
Cloud cloudprovider.Interface
EtcdHelper tools.EtcdHelper
EventTTL time.Duration
MinionRegexp string
KubeletClient client.KubeletClient
PortalNet *net.IPNet
EnableLogsSupport bool
EnableUISupport bool
EnableSwaggerSupport bool
EnableV1Beta3 bool
Client *client.Client
Cloud cloudprovider.Interface
EtcdHelper tools.EtcdHelper
EventTTL time.Duration
MinionRegexp string
KubeletClient client.KubeletClient
PortalNet *net.IPNet
EnableLogsSupport bool
EnableUISupport bool
// allow downstream consumers to disable swagger
EnableSwaggerSupport bool
// allow v1beta3 to be conditionally enabled
EnableV1Beta3 bool
// allow downstream consumers to disable the index route
EnableIndex bool
APIPrefix string
CorsAllowedOriginList util.StringList
Authenticator authenticator.Request
@@ -384,7 +388,10 @@ func (m *Master) init(c *Config) {
// Register root handler.
// We do not register this using restful Webservice since we do not want to surface this in api docs.
m.mux.HandleFunc("/", apiserver.IndexHandler(m.handlerContainer, m.muxHelper))
// Allow master to be embedded in contexts which already have something registered at the root
if c.EnableIndex {
m.mux.HandleFunc("/", apiserver.IndexHandler(m.handlerContainer, m.muxHelper))
}
// TODO: use go-restful
apiserver.InstallValidator(m.muxHelper, func() map[string]apiserver.Server { return m.getServersToValidate(c) })

View File

@@ -247,6 +247,7 @@ func (s *APIServer) Run(_ []string) error {
EnableLogsSupport: s.EnableLogsSupport,
EnableUISupport: true,
EnableSwaggerSupport: true,
EnableIndex: true,
APIPrefix: s.APIPrefix,
CorsAllowedOriginList: s.CorsAllowedOriginList,
ReadOnlyPort: s.ReadOnlyPort,