Documentation
¶
Index ¶
- func BuildIptablesGoldenFileName(image, cmd, suffix string) []string
- func CleanIptablesSaveOutput(output string) string
- func FromTemplate(g gomega.Gomega, tmpl string, data any) string
- func GetFreePort() (int, error)
- func HasPanicInCpLogs(logs string) bool
- func Indent(pem string, padding int) string
- func ShellEscape(arg string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildIptablesGoldenFileName ¶
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 ¶
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:
- Removes comment lines that start with "#" to eliminate lines containing dynamic data such as timestamps or identifiers that vary between runs.
- 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 GetFreePort ¶
func HasPanicInCpLogs ¶ added in v2.10.9
func ShellEscape ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.