Skip to content

Commit

Permalink
150 segmentation violation (#151)
Browse files Browse the repository at this point in the history
* Added cluster=scoped-rbac flag and exporting all these resources in the _cluster folder

* Added ClusterScopeHandler and implemented filtering functions

* Fixed wrong handling of optional flag and set default to false

* typo: Adding SCC when users match

* Moving _clusters under the namespace folder, to have one instance for each exported namespace

* Added admittedResource type to propertly manage resources with same name in differernt groups
Using range instead of reverse loop by index
Reverted use of go 1.18 (removed slices package)

* Update cmd/export/cluster.go

Co-authored-by: David Zager <dzager@redhat.com>

* Update cmd/export/cluster.go

Co-authored-by: David Zager <dzager@redhat.com>

* Fix for #150: initialized filteredClusterRoleBindings

* Added error message

* integrated reviewer's comment

---------

Co-authored-by: David Zager <dzager@redhat.com>
  • Loading branch information
dmartinol and djzager authored Mar 10, 2023
1 parent d14f18b commit a3e4a57
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/export/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
authv1 "github.com/openshift/api/authorization/v1"
securityv1 "github.com/openshift/api/security/v1"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -106,7 +107,18 @@ func (c *ClusterScopedRbacHandler) prepareForFiltering() {
}
}
c.filteredClusterRoleBindings.objects = &filteredClusterRoleBindings
return
}

c.filteredClusterRoleBindings = &groupResource{
APIGroup: "NA",
APIVersion: "NA",
APIGroupVersion: "NA",
APIResource: metav1.APIResource{},
}
c.filteredClusterRoleBindings.objects = &unstructured.UnstructuredList{Items: []unstructured.Unstructured{}}
c.log.Error("The export of cluster level RBAC resources is enabled but no ClusterRoleBinding resources have been collected:" +
" the actual error message can be found under the failures folder")
}

func (c *ClusterScopedRbacHandler) filteredResourcesOfKind(resource admittedResource) (*groupResource, bool) {
Expand Down

0 comments on commit a3e4a57

Please sign in to comment.