Skip to content

Commit

Permalink
Merge pull request #232 from grantr/panic-not-exit
Browse files Browse the repository at this point in the history
🐛 Panic instead of Exit in FakeClient
  • Loading branch information
k8s-ci-robot committed Apr 5, 2019
2 parents 0d6f672 + 43e769a commit 86f461a
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/client/fake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"

"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -32,14 +31,9 @@ import (

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
"sigs.k8s.io/controller-runtime/pkg/internal/objectutil"
)

var (
log = logf.RuntimeLog.WithName("fake-client")
)

type fakeClient struct {
tracker testing.ObjectTracker
scheme *runtime.Scheme
Expand All @@ -63,9 +57,7 @@ func NewFakeClientWithScheme(clientScheme *runtime.Scheme, initObjs ...runtime.O
for _, obj := range initObjs {
err := tracker.Add(obj)
if err != nil {
log.Error(err, "failed to add object to fake client", "object", obj)
os.Exit(1)
return nil
panic(fmt.Errorf("failed to add object %v to fake client: %v", obj, err))
}
}
return &fakeClient{
Expand Down

0 comments on commit 86f461a

Please sign in to comment.