unittestutils

package
v0.0.0-...-44dad58 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const DisallowAddCapabilities = `` /* 466-byte string literal not displayed */
View Source
const DisallowBindMounts = `` /* 377-byte string literal not displayed */
View Source
const DisallowHostIPC = `` /* 349-byte string literal not displayed */
View Source
const DisallowHostPID = `` /* 349-byte string literal not displayed */
View Source
const DisallowNetworkPorts = `` /* 634-byte string literal not displayed */
View Source
const DisallowNodePortServices = `` /* 422-byte string literal not displayed */
View Source
const DisallowPrivilegedContainers = `` /* 627-byte string literal not displayed */
View Source
const DisallowPrivilegedEscalation = `` /* 604-byte string literal not displayed */
View Source
const DisallowRootUser = `` /* 573-byte string literal not displayed */

Variables

View Source
var ServiceAccounts []*corev1.ServiceAccount
View Source
var Tenantnamespaces []*tenancyv1alpha1.TenantNamespace

In future if we want to add more tenants and tenantnamespaces

Functions

func CheckNamespaceExist

func CheckNamespaceExist(namespace string, k8sClient *kubernetes.Clientset) bool

CheckNamespaceExist namespace exists or not

func NamespaceObj

func NamespaceObj(name string) *corev1.Namespace

func ServiceAccountObj

func ServiceAccountObj(name string, namespace string) *corev1.ServiceAccount

ServiceAccountObj returns the pointer to a service account object

func WaitForKyvernoToReady

func WaitForKyvernoToReady(k8sClient *kubernetes.Clientset) error

func WaitForPolicy

func WaitForPolicy() error

Types

type KindCluster

type KindCluster struct {
	Name           string
	Nodes          int
	KubeConfig     string
	KubeConfigFile string
	Provider       *cluster.Provider
}

KindCluster configures the Kind Cluster

func (*KindCluster) CreateCluster

func (k *KindCluster) CreateCluster() error

Creates Cluster

func (*KindCluster) DeleteCluster

func (k *KindCluster) DeleteCluster() error

Delete Kind Cluster

type TestClient

type TestClient struct {
	Kubernetes             kubernetes.Interface
	APIExtensions          apiextensionspkg.Interface
	REST                   restpkg.Interface
	Config                 *restpkg.Config
	RoleName               string
	RoleBindingName        string
	ResourcePath           string
	ClusterRoleBindingName string
	ClusterRoleName        string
	DynamicResource        dynamic.ResourceInterface
	PolicyName             string
	TenantClient           *kubernetes.Clientset
	K8sClient              *kubernetes.Clientset

	Namespace      string
	ServiceAccount *corev1.ServiceAccount
	Context        contextpkg.Context
	Log            *logging.Logger
}

TestClient contains fields required to run unittests

func TestNewClient

func TestNewClient(loggerName string, k8sClient *kubernetes.Clientset, apiExtensions apiextensionspkg.Interface, rest restpkg.Interface, config *restpkg.Config) *TestClient

func (*TestClient) CreateClusterRole

func (client *TestClient) CreateClusterRole(clusterRoleName string, policy []v1.PolicyRule) (*v1.ClusterRole, error)

func (*TestClient) CreateClusterRoleBinding

func (client *TestClient) CreateClusterRoleBinding(clusterRoleBindingName string, clusterRole *v1.ClusterRole) (*v1.ClusterRoleBinding, error)

func (*TestClient) CreatePolicy

func (self *TestClient) CreatePolicy(resourcePath string) error

func (*TestClient) CreateRole

func (client *TestClient) CreateRole(roleName string, policy []v1.PolicyRule) (*v1.Role, error)

func (*TestClient) CreateRoleBinding

func (client *TestClient) CreateRoleBinding(roleBindingName string, role *v1.Role) (*v1.RoleBinding, error)

func (*TestClient) DeleteClusterRole

func (client *TestClient) DeleteClusterRole() error

func (*TestClient) DeletePolicy

func (self *TestClient) DeletePolicy() error

func (*TestClient) DeleteRole

func (client *TestClient) DeleteRole() error

Jump to

Keyboard shortcuts

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