hba

package
v1.29.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hba provides utilities for handling PostgreSQL Host-Based Authentication (pg_hba.conf) rules, including validation and expansion of descriptor references such as pod selectors.

Index

Constants

View Source
const PodSelectorReference = "podselector"

PodSelectorReference is the type of references to a Pod selector.

Variables

This section is empty.

Functions

func ExpandLine

func ExpandLine(line string, selectorIPs map[string][]string) []string

ExpandLine expands descriptor references in an HBA line. Only the first descriptor reference is expanded; lines with multiple references should be rejected by ValidateLine before reaching this point. Returns one line per expanded value. If the line has no descriptor reference, returns a slice containing just the original line. If an error occurs, the line is returned as a comment with the error message appended. This function is also registered as a Go template FuncMap entry ("expandRule") for inline expansion in the pg_hba.conf template.

func ValidateLine

func ValidateLine(line string, knownSelectors *stringset.Data) error

ValidateLine validates a PostgreSQL HBA line, checking that all descriptor references are of known types, that at most one podselector reference is present, and that referenced selectors exist.

Types

type ErrMultiplePodSelectorReferences

type ErrMultiplePodSelectorReferences struct {
	Count int
}

ErrMultiplePodSelectorReferences is returned when an HBA line contains more than one podselector reference.

func (*ErrMultiplePodSelectorReferences) Error

type ErrPodSelectorNotFound

type ErrPodSelectorNotFound struct {
	SelectorName string
}

ErrPodSelectorNotFound is returned when an HBA line references a pod selector that is not present in the provided map.

func (*ErrPodSelectorNotFound) Error

func (e *ErrPodSelectorNotFound) Error() string

type ErrUnknownDescriptorType

type ErrUnknownDescriptorType struct {
	DescriptorType string
}

ErrUnknownDescriptorType is returned when an HBA line contains a descriptor reference with an unknown type.

func (*ErrUnknownDescriptorType) Error

func (e *ErrUnknownDescriptorType) Error() string

Jump to

Keyboard shortcuts

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