Documentation
¶
Index ¶
- type AnnoKindMatcher
- type ConvertedLegacyAnnotations
- type KindMatcher
- type KindMatchers
- type MatchExpressionMatcher
- type MatchLabelsMatcher
- type Matchers
- type MetaData
- type Parameter
- type Rego
- func (r Rego) AnnotationExcludedNamespaceMatchers() []string
- func (r Rego) AnnotationKindMatchers() []AnnoKindMatcher
- func (r Rego) AnnotationLabelSelectorMatcher() *metav1.LabelSelector
- func (r Rego) AnnotationNamespaceMatchers() []string
- func (r Rego) AnnotationParameters() map[string]apiextensionsv1.JSONSchemaProps
- func (r Rego) Annotations() map[string]string
- func (r Rego) ConvertLegacyAnnotations() (*ConvertedLegacyAnnotations, error)
- func (r Rego) Dependencies() []string
- func (r Rego) Description() string
- func (r Rego) Enforcement() string
- func (r Rego) FullSource() string
- func (r Rego) GetAnnotation(name string) (any, bool)
- func (r Rego) GetOpenAPISchemaProperties() map[string]apiextensionsv1.JSONSchemaProps
- func (r Rego) HasMetadataAnnotations() bool
- func (r Rego) Kind() string
- func (r Rego) Labels() map[string]string
- func (r Rego) LegacyConversionSource() string
- func (r Rego) Matchers() (Matchers, error)
- func (r Rego) Name() string
- func (r Rego) Parameters() []Parameter
- func (r Rego) Path() string
- func (r Rego) PolicyID() string
- func (r Rego) Severity() Severity
- func (r Rego) SkipConstraint() bool
- func (r Rego) SkipTemplate() bool
- func (r Rego) Source() string
- func (r Rego) Title() string
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnnoKindMatcher ¶
type AnnoKindMatcher struct { APIGroups []string `json:"apiGroups,omitempty"` Kinds []string `json:"kinds,omitempty"` }
func (AnnoKindMatcher) String ¶
func (akm AnnoKindMatcher) String() string
type ConvertedLegacyAnnotations ¶
type ConvertedLegacyAnnotations struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Custom map[string]any `json:"custom,omitempty"` }
ConvertedLegacyAnnotations holds OPA Metadata Annotations, which were converted from legacy style annotations
type KindMatcher ¶
KindMatcher is the matcher to generate `constraints.spec.match.kinds`
type KindMatchers ¶
type KindMatchers []KindMatcher
KindMatchers is a slice of KindMatcher
func (KindMatchers) String ¶
func (k KindMatchers) String() string
func (KindMatchers) ToSpec ¶
func (k KindMatchers) ToSpec() []any
ToSpec converts KindMatchers to a slice in format compatible with `spec.match.kinds` of a Constraint
type MatchExpressionMatcher ¶
type MatchExpressionMatcher struct { Key string `json:"key"` Operator string `json:"operator"` Values []string `json:"values,omitempty"` }
MatchExpressionsMatcher is the matcher to generate `constraints.spec.match.labelSelector.matchExpressions`.
type MatchLabelsMatcher ¶
MatchLabelsMatcher is the matcher to generate `constraints.spec.match.labelSelector.matchLabels`.
func (MatchLabelsMatcher) String ¶
func (m MatchLabelsMatcher) String() string
type Matchers ¶
type Matchers struct { KindMatchers KindMatchers MatchLabelsMatcher MatchLabelsMatcher MatchExpressionsMatcher []MatchExpressionMatcher NamespaceMatcher []string ExcludedNamespaceMatcher []string }
Matchers are all of the matchers that can be applied to constraints.
type Rego ¶
type Rego struct {
// contains filtered or unexported fields
}
Rego represents a parsed rego file.
func GetAllSeverities ¶
GetAllSeverities gets all of the rego files found in the given directory as well as any subdirectories. Only rego files that contain a valid severity will be returned.
func GetAllSeveritiesWithoutImports ¶
GetAllSeveritiesWithoutImports gets all of the Rego files found in the given directory as well as any subdirectories, but does not attempt to parse the imports.
func GetViolations ¶
GetViolations gets all of the files found in the given directory as well as any subdirectories. Only rego files that have a severity of violation will be returned.
func (Rego) AnnotationExcludedNamespaceMatchers ¶
func (Rego) AnnotationKindMatchers ¶
func (r Rego) AnnotationKindMatchers() []AnnoKindMatcher
func (Rego) AnnotationLabelSelectorMatcher ¶
func (r Rego) AnnotationLabelSelectorMatcher() *metav1.LabelSelector
func (Rego) AnnotationNamespaceMatchers ¶
func (Rego) AnnotationParameters ¶
func (r Rego) AnnotationParameters() map[string]apiextensionsv1.JSONSchemaProps
func (Rego) Annotations ¶
Annotations returns the annotations found in the header comment of the rego file.
func (Rego) ConvertLegacyAnnotations ¶
func (r Rego) ConvertLegacyAnnotations() (*ConvertedLegacyAnnotations, error)
ConvertLegacyAnnotations converts legacy annotations to ConvertedLegacyAnnotations
func (Rego) Dependencies ¶
Dependencies returns all of the source for the rego files that this rego file depends on.
func (Rego) Description ¶
Description returns the entire description found in the header comment of the Rego file.
func (Rego) Enforcement ¶
Enforcement returns the enforcement action in the header comment. Defaults to deny if no enforcement action is specified.
func (Rego) FullSource ¶
FullSource returns the original source code inside of the rego file including comments except the header
func (Rego) GetOpenAPISchemaProperties ¶
func (r Rego) GetOpenAPISchemaProperties() map[string]apiextensionsv1.JSONSchemaProps
func (Rego) HasMetadataAnnotations ¶
HasMetadataAnnotations checks whether rego file has OPA Metadata Annotations
func (Rego) Kind ¶
Kind returns the Kubernetes Kind of the rego file. The kind of the rego file is determined by the name of the directory that the rego file exists in.
func (Rego) LegacyConversionSource ¶
LegacyConversionSource returns the original source code with comments except header, but doesn't trim any trailing whitespace
func (Rego) Name ¶
Name returns the name of the rego file. The name of the rego file is its kind as lowercase.
func (Rego) Parameters ¶
Parameters returns the list of parsed parameters
func (Rego) PolicyID ¶
PolicyID returns the identifier of the policy. The returned value will be a blank string if an id was not specified in the policy body.
func (Rego) Severity ¶
Severity returns the severity of the rego file. When a rego file has multiple rules that are considered to be different severities, the first rule is chosen.
func (Rego) SkipConstraint ¶
SkipConstraint returns whether or not the generation of the Constraint should be skipped. It is only set to true when the @skip-constraint tag is present in the comment header block
func (Rego) SkipTemplate ¶
SkipTemplate returns whether or not the generation of the Template should be skipped. It is only set to true when the @skip-template tag is present in the comment header block