Skip to content

Commit

Permalink
add test, fix wording in errors.go
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri committed Jul 19, 2023
1 parent 5e4945c commit db45ca3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module sigs.k8s.io/controller-runtime
go 1.20

require (
github.com/davecgh/go-spew v1.1.1
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/evanphx/json-patch/v5 v5.6.0
github.com/fsnotify/fsnotify v1.6.0
Expand Down Expand Up @@ -31,6 +30,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand Down
6 changes: 3 additions & 3 deletions pkg/cache/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// ErrResourceNotCached indicates that the resource type the client asked the cache for is not cached, and
// the cache is configured to fail on a cache miss.
// ErrResourceNotCached indicates that the resource type
// the client asked the cache for is not cached.
type ErrResourceNotCached struct {
GVK schema.GroupVersionKind
}

// Error returns the error
func (r ErrResourceNotCached) Error() string {
return fmt.Sprintf("%s is not cached and the cache is configured to fail on miss", r.GVK.String())
return fmt.Sprintf("%s is not cached", r.GVK.String())
}

var _ error = (*ErrResourceNotCached)(nil)
10 changes: 10 additions & 0 deletions pkg/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,16 @@ var _ = Describe("manger.Manager", func() {
Expect(listener.Close()).ToNot(HaveOccurred())
})

It("should should be able to create a manager with a cache to fail on unknown resources", func() {
m, err := New(cfg, Options{
Cache: cache.Options{
FailOnUnknownResource: true,
},
})
Expect(m).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
})

It("should return an error if the metrics bind address is already in use", func() {
ln, err := metrics.NewListener(":0")
Expect(err).ShouldNot(HaveOccurred())
Expand Down

0 comments on commit db45ca3

Please sign in to comment.