aclcsv

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package aclcsv provides pure CSV serialization/parsing of ACL bindings and a declarative sync (diff + apply) between a desired binding set and the cluster.

Index

Constants

This section is empty.

Variables

View Source
var Header = []string{"Principal", "ResourceType", "PatternType", "ResourceName", "Operation", "PermissionType", "Host"}

Header is the fixed CSV column order emitted by Marshal and accepted (optionally) by Parse.

Functions

func Marshal

func Marshal(entries []api.ACLEntry) string

Marshal serializes bindings as CSV with the fixed header. Fields containing commas (e.g. SSL DN principals) are quoted by the encoding/csv writer.

func Parse

func Parse(s string) ([]api.ACLEntry, error)

Parse reads CSV text into ACL bindings. It skips blank lines and an optional header (case-insensitive, spaces ignored), and rejects lines without exactly 7 columns, blank values, or unrecognized resource type / pattern type / operation / permission — reporting the offending line (and column).

Types

type CSVParseError

type CSVParseError struct {
	Line   int
	Column int
	Reason string
}

CSVParseError describes a malformed CSV line. Column is 1-based and 0 when the error applies to the whole line.

func (CSVParseError) Error

func (e CSVParseError) Error() string

type SyncPlan

type SyncPlan struct {
	ToCreate []api.ACLEntry
	ToDelete []api.ACLEntry
}

SyncPlan is the set difference between a desired binding set and the cluster's current bindings, computed on full 7-field binding identity.

func SyncACLs

func SyncACLs(ds api.KafkaDataSource, desired []api.ACLEntry) (SyncPlan, error)

SyncACLs fetches the current ACLs and computes the plan to reconcile them toward desired. It does not mutate the cluster — call SyncPlan.Apply for that.

func (SyncPlan) Apply

func (p SyncPlan) Apply(ds api.KafkaDataSource) error

Apply creates the missing bindings and deletes the extra ones, logging the plan. It is a no-op for an empty plan.

func (SyncPlan) Empty

func (p SyncPlan) Empty() bool

Empty reports whether the plan is a no-op (cluster already in sync).

Jump to

Keyboard shortcuts

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