mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 05:30:26 +00:00
Updating methods to return error rather than using glog.Fatalf
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user