diff --git a/pkg/nuke/scan.go b/pkg/nuke/scan.go index 20133e6..01d6ba1 100644 --- a/pkg/nuke/scan.go +++ b/pkg/nuke/scan.go @@ -119,7 +119,7 @@ func (s *Scanner) list(owner, resourceType string, opts interface{}) { } dump := utils.Indent(fmt.Sprintf("%v", err), " ") - logrus.Errorf("Listing %s failed:\n%s", resourceType, dump) + logrus.WithError(err).Errorf("Listing %s failed:\n%s", resourceType, dump) return } diff --git a/pkg/resource/registry.go b/pkg/resource/registry.go index f3691d6..534523e 100644 --- a/pkg/resource/registry.go +++ b/pkg/resource/registry.go @@ -7,9 +7,14 @@ import ( "github.com/stevenle/topsort" ) -// Scope is a string in which resources are grouped against +// Scope is a string in which resources are grouped against, this is meant for upstream tools to define their +// own scopes if the DefaultScope is not sufficient. For example Azure has multiple levels of scoping for resources, +// whereas AWS does not. type Scope string +// DefaultScope is the default scope which resources are registered against if no other scope is provided +const DefaultScope Scope = "default" + // Registrations is a map of resource type to registration type Registrations map[string]Registration @@ -45,11 +50,10 @@ type RegisterOption func(name string, lister Lister) // Register registers a resource lister with the registry func Register(r Registration, opts ...RegisterOption) { if r.Scope == "" { - panic(fmt.Errorf("scope must be set")) + r.Scope = DefaultScope } - _, exists := registrations[r.Name] - if exists { + if _, exists := registrations[r.Name]; exists { panic(fmt.Sprintf("a resource with the name %s already exists", r.Name)) }