moving genericapiserver command line flags to genericapiserver

This commit is contained in:
nikhiljindal 2016-04-06 15:24:48 -07:00
parent 599369872e
commit 2e712473aa
3 changed files with 18 additions and 6 deletions

View File

@ -55,7 +55,14 @@ func newStorageDestinations(groupName string, groupMeta *apimachinery.GroupMeta)
return &storageDestinations, nil
}
func Run() error {
func NewServerRunOptions() *genericapiserver.ServerRunOptions {
serverOptions := genericapiserver.NewServerRunOptions()
serverOptions.InsecurePort = InsecurePort
serverOptions.SecurePort = SecurePort
return serverOptions
}
func Run(serverOptions *genericapiserver.ServerRunOptions) error {
config := genericapiserver.Config{
EnableIndex: true,
EnableSwaggerSupport: true,
@ -92,9 +99,6 @@ func Run() error {
if err := s.InstallAPIGroups([]genericapiserver.APIGroupInfo{apiGroupInfo}); err != nil {
return fmt.Errorf("Error in installing API: %v", err)
}
serverOptions := genericapiserver.NewServerRunOptions()
serverOptions.InsecurePort = InsecurePort
serverOptions.SecurePort = SecurePort
s.Run(serverOptions)
return nil
}

View File

@ -41,7 +41,7 @@ var groupVersionForDiscovery = unversioned.GroupVersionForDiscovery{
func TestRun(t *testing.T) {
go func() {
if err := Run(); err != nil {
if err := Run(NewServerRunOptions()); err != nil {
t.Fatalf("Error in bringing up the server: %v", err)
}
}()

View File

@ -18,12 +18,20 @@ package main
import (
"k8s.io/kubernetes/examples/apiserver"
"k8s.io/kubernetes/pkg/util/flag"
"github.com/golang/glog"
"github.com/spf13/pflag"
)
func main() {
if err := apiserver.Run(); err != nil {
serverRunOptions := apiserver.NewServerRunOptions()
// Parse command line flags.
serverRunOptions.AddFlags(pflag.CommandLine)
flag.InitFlags()
if err := apiserver.Run(serverRunOptions); err != nil {
glog.Fatalf("Error in bringing up the server: %v", err)
}
}