block_cluster_resources

package
v0.0.0-...-edbd4c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BCRbenchmark = &benchmark.Benchmark{
		Run: func(tenant, tenantNamespace string, kclient, tclient *kubernetes.Clientset) (bool, error) {
			resources := []util.GroupResource{}

			lists, err := kclient.Discovery().ServerPreferredResources()
			if err != nil {
				return false, err
			}

			for _, list := range lists {
				if len(list.APIResources) == 0 {
					continue
				}
				gv, err := schema.ParseGroupVersion(list.GroupVersion)
				if err != nil {
					continue
				}
				for _, resource := range list.APIResources {
					if len(resource.Verbs) == 0 {
						continue
					}

					if resource.Namespaced {
						continue
					}
					resources = append(resources, util.GroupResource{
						APIGroup:    gv.Group,
						APIResource: resource,
					})
				}
			}

			for _, resource := range resources {
				for _, verb := range verbs {
					access, msg, err := util.RunAccessCheck(tclient, tenantNamespace, resource, verb)
					if err != nil {
						return false, err
					}
					if access {
						return false, fmt.Errorf(msg)
					}

				}
			}
			return true, nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL