conversion

package
v0.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conversion holds what the WAFPolicy conversion webhook needs when v1 is served next to v1alpha1 (#708, #64). Only WAFPolicy changes shape at v1; the other kinds convert with conversion: None. Nothing serves v1 yet: these types and functions fix the v1 shapes now, so that what v1 freezes is decided, and tested, before v1.0.0.

What changes, v1alpha1 to v1:

  • spec.ipLists.allow[] and .deny[]: a WAFIPList name ("abusers") becomes a reference, {kind: WAFIPList, name: abusers}, so that a cluster-wide ClusterWAFIPList can be added later without a breaking change (IPListReference).
  • spec.ruleSets[].ref.namespace: dropped. It can only name the policy's own namespace (the resolver refuses any other), so dropping it loses nothing; cross-namespace references would come back with a grant kind (RuleSetNamespace).
  • spec.ruleSets[].paranoiaLevel and .inboundAnomalyThreshold: moved to crs (#714).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPListNames

func IPListNames(refs []IPListReference) ([]wafv1alpha1.IPListName, error)

IPListNames converts v1 references back to v1alpha1 names. v1alpha1 can only name a WAFIPList, so a ClusterWAFIPList, once it exists, has no v1alpha1 form: an error, which the conversion webhook returns rather than drop the reference.

func RuleSetNamespace

func RuleSetNamespace(ref wafv1alpha1.RuleSetRef, policyNamespace string) error

RuleSetNamespace checks that v1 loses nothing by dropping a v1alpha1 rule set reference's namespace: unset, or the policy's own. Another namespace is an error: such a policy was never Accepted, v1 couldn't say it, and converting it as the policy's namespace could bind a different rule set, so the v1.0 upgrade preflight refuses while one exists (the webhook warns of it from 0.7.0).

Types

type IPListKind

type IPListKind string

IPListKind is the kind of an IP list a v1 policy references. +kubebuilder:validation:Enum=WAFIPList;ClusterWAFIPList

const (
	KindWAFIPList        IPListKind = "WAFIPList"
	KindClusterWAFIPList IPListKind = "ClusterWAFIPList"
)

The IP list kinds. Only WAFIPList exists; ClusterWAFIPList is planned (docs/design/0004 §3, 0002 §4.2).

type IPListReference

type IPListReference struct {
	// Kind is WAFIPList, in the policy's namespace (the default), or
	// ClusterWAFIPList.
	// +kubebuilder:default=WAFIPList
	// +optional
	Kind IPListKind `json:"kind,omitempty"`

	// Name of the list.
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	Name string `json:"name"`
}

IPListReference is the v1 item of spec.ipLists.allow and .deny. The lists are +listType=map, keyed by kind and name.

func IPListReferences

func IPListReferences(names []wafv1alpha1.IPListName) []IPListReference

IPListReferences converts v1alpha1 list names to v1 references: each names a WAFIPList.

Jump to

Keyboard shortcuts

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