Updating methods to return error rather than using glog.Fatalf

This commit is contained in:
nikhiljindal
2016-02-03 14:26:11 -08:00
parent 2aa28c6553
commit c7beb9078c
16 changed files with 128 additions and 38 deletions

View File

@@ -17,7 +17,8 @@ limitations under the License.
package apiserver
import (
"github.com/golang/glog"
"fmt"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup/v1"
testgroupetcd "k8s.io/kubernetes/examples/apiserver/rest"
"k8s.io/kubernetes/pkg/api"
@@ -45,24 +46,27 @@ func newStorageDestinations(groupName string, groupMeta *apimachinery.GroupMeta)
return &storageDestinations, nil
}
func Run() {
func Run() error {
config := genericapiserver.Config{
EnableIndex: true,
APIPrefix: "/api",
APIGroupPrefix: "/apis",
Serializer: api.Codecs,
}
s := genericapiserver.New(&config)
s, err := genericapiserver.New(&config)
if err != nil {
return fmt.Errorf("Error in bringing up the server: %v", err)
}
groupVersion := v1.SchemeGroupVersion
groupName := groupVersion.Group
groupMeta, err := registered.Group(groupName)
if err != nil {
glog.Fatalf("%v", err)
return fmt.Errorf("%v", err)
}
storageDestinations, err := newStorageDestinations(groupName, groupMeta)
if err != nil {
glog.Fatalf("Unable to init etcd: %v", err)
return fmt.Errorf("Unable to init etcd: %v", err)
}
restStorageMap := map[string]rest.Storage{
"testtypes": testgroupetcd.NewREST(storageDestinations.Get(groupName, "testtype"), s.StorageDecorator()),
@@ -76,7 +80,8 @@ func Run() {
NegotiatedSerializer: api.Codecs,
}
if err := s.InstallAPIGroups([]genericapiserver.APIGroupInfo{apiGroupInfo}); err != nil {
glog.Fatalf("Error in installing API: %v", err)
return fmt.Errorf("Error in installing API: %v", err)
}
s.Run(genericapiserver.NewServerRunOptions())
return nil
}