utils

package
v2.13.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIptablesGoldenFileName

func BuildIptablesGoldenFileName(image, cmd, suffix string) []string

BuildIptablesGoldenFileName constructs the complete file path for a golden file used for storing expected iptables rules based on a specific test configuration.

Args:

  • image (string): The Docker image name used for testing.
  • cmd (string): The iptables save command used in the test.
  • suffix (string): The optional suffix to be added to the file name.

Returns:

  • []string: A slice of strings representing the complete file path for the golden file. The first element is the subdirectory "testdata", and the second element is the actual golden file name based on the sanitized image name and flags joined with hyphens, ending with the command and ".golden" suffix.

Example:

BuildIptablesGoldenFileName("RHEL 8", "iptables-save", "redirect-dns")
# Returns ["testdata", "rhel-8-redirect-dns.iptables.golden"]

func CleanIptablesSaveOutput

func CleanIptablesSaveOutput(output string) string

CleanIptablesSaveOutput processes the provided iptables-save output by removing comment lines and normalizing variable content for consistent comparison with golden files.

Specifically, the function performs the following steps:

  1. Removes comment lines that start with "#" to eliminate lines containing dynamic data such as timestamps or identifiers that vary between runs.
  2. Uses regular expressions to replace certain patterns that may differ between runs, ensuring the output is standardized. For example, interface names are replaced with a placeholder to facilitate consistent comparison.

The resulting cleaned output is more stable for comparison with golden files by removing elements that can change between runs, allowing for accurate regression testing.

func FromTemplate

func FromTemplate(g gomega.Gomega, tmpl string, data any) string

func GetFreePort

func GetFreePort() (int, error)

func HasPanicInCpLogs added in v2.10.9

func HasPanicInCpLogs(logs string) bool

func Indent added in v2.13.0

func Indent(pem string, padding int) string

func ShellEscape

func ShellEscape(arg string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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