Documentation ¶
Index ¶
- Variables
- func NewK8sUserInfo(u UserInfo) user.DefaultInfo
- func Run(cfg CmdConfig, pathList []string) error
- func RunInit(cfg CmdConfig, targetFilePath string) error
- type CmdConfig
- type GVK
- type NameWithGVK
- type NamespacedName
- type PolicyDecisionExpect
- type ResourceLoader
- type TestCase
- type TestManifests
- type TestsForSinglePolicy
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTestFail = errors.New("test failed")
Functions ¶
func NewK8sUserInfo ¶
func NewK8sUserInfo(u UserInfo) user.DefaultInfo
Types ¶
type NameWithGVK ¶
type NameWithGVK struct { GVK `yaml:",inline"` NamespacedName `yaml:",inline"` }
func NewNameWithGVK ¶
func NewNameWithGVK(gvk schema.GroupVersionKind, namespacedName NamespacedName) NameWithGVK
NewNameWithGVK creates NameWithGVK from GVK and NamespacedName.
func NewNameWithGVKFromObj ¶
func NewNameWithGVKFromObj(obj *unstructured.Unstructured) NameWithGVK
NewNameWithGVKFromObj creates NameWithGVK from unstructured object.
func (NameWithGVK) IsValid ¶
func (n NameWithGVK) IsValid() bool
func (NameWithGVK) Match ¶
func (query NameWithGVK) Match(given NameWithGVK) bool
func (NameWithGVK) String ¶
func (n NameWithGVK) String() string
type NamespacedName ¶
type NamespacedName struct { Namespace string `yaml:"namespace,omitempty"` Name string `yaml:"name"` }
func (NamespacedName) IsValid ¶
func (n NamespacedName) IsValid() bool
func (NamespacedName) String ¶
func (n NamespacedName) String() string
type PolicyDecisionExpect ¶
type PolicyDecisionExpect string
const ( Admit PolicyDecisionExpect = "admit" Deny PolicyDecisionExpect = "deny" Error PolicyDecisionExpect = "error" Skip PolicyDecisionExpect = "skip" )
type ResourceLoader ¶
type ResourceLoader struct { Vaps map[string]*v1.ValidatingAdmissionPolicy Resources map[NameWithGVK]*unstructured.Unstructured }
func NewResourceLoader ¶
func NewResourceLoader() *ResourceLoader
func (*ResourceLoader) GetResource ¶
func (r *ResourceLoader) GetResource(ngvk NameWithGVK) (*unstructured.Unstructured, error)
func (*ResourceLoader) LoadResources ¶
func (r *ResourceLoader) LoadResources(paths []string)
func (*ResourceLoader) LoadVaps ¶
func (r *ResourceLoader) LoadVaps(paths []string)
type TestCase ¶
type TestCase struct { Object NameWithGVK `yaml:"object,omitempty"` OldObject NameWithGVK `yaml:"oldObject,omitempty"` Param NamespacedName `yaml:"param,omitempty"` Expect PolicyDecisionExpect `yaml:"expect,omitempty"` UserInfo UserInfo `yaml:"userInfo,omitempty"` }
TestCase is a struct to represent a single test case.
type TestManifests ¶
type TestManifests struct { ValidatingAdmissionPolicies []string `yaml:"validatingAdmissionPolicies,omitempty"` Resources []string `yaml:"resources,omitempty"` TestSuites []TestsForSinglePolicy `yaml:"testSuites,omitempty"` }
TestManifests is a struct to represent the whole test manifest file.
func (TestManifests) IsValid ¶
func (t TestManifests) IsValid() (bool, string)
type TestsForSinglePolicy ¶
TestsForSinglePolicy is a struct to aggregate multiple test cases for a single policy.
Click to show internal directories.
Click to hide internal directories.