Documentation
¶
Overview ¶
Package configstoresync holds pure helpers shared by the KonnectConfigStoreSync controller and the conflict field indexer: store key derivation, entry resolution, value building and hashing. Keeping them here (instead of in controller/konnect) lets internal/utils/index import them without creating an import cycle.
Index ¶
- Constants
- func CombinedValue(certPEM, keyPEM []byte) ([]byte, error)
- func DerivedKey(namespace, name string) string
- func DuplicateStoreKeys(entries []ResolvedEntry) []string
- func ReferenceSuffixes(entry ResolvedEntry) []konnectv1alpha1.KonnectConfigStoreSyncReference
- func ValidateX509KeyPair(certPEM, keyPEM []byte) (notAfter time.Time, err error)
- func ValueHash(value []byte) string
- type ResolvedEntry
Constants ¶
const ( // MaxKeyBytes is the Konnect Config Store key size cap (512 bytes). // Explicit storeKeys are capped by CRD validation, but derived keys are // not: a 63-char namespace, 253-char name and 253-char Split field derive // a ~582-byte key. The controller enforces this cap pre-write and reports // KeyTooLong instead of pushing. MaxKeyBytes = 512 // MaxValueCharacters is the Konnect Config Store value cap in Unicode code points. MaxValueCharacters = 8192 // CombinedCertificateSubField is the frozen JSON subfield holding the // certificate in a Combined mode entry value. CombinedCertificateSubField = "certificate" // CombinedKeySubField is the frozen JSON subfield holding the private key // in a Combined mode entry value. CombinedKeySubField = "key" )
Variables ¶
This section is empty.
Functions ¶
func CombinedValue ¶
CombinedValue builds the Combined mode entry value from the certificate and key PEM data.
func DerivedKey ¶
DerivedKey returns the store key derived from the sync's identity using the length-prefixed format k8s-<len(namespace)>-<namespace>-<len(name)>-<name>. The length prefixes make the encoding unambiguous: no two distinct (namespace, name) pairs can produce the same derived key.
func DuplicateStoreKeys ¶
func DuplicateStoreKeys(entries []ResolvedEntry) []string
DuplicateStoreKeys returns the store keys claimed by more than one resolved entry, or nil when all keys are distinct. Status entries are list-keyed by storeKey, so duplicates would both double-write the same Config Store entry and be rejected by the API server on status update.
func ReferenceSuffixes ¶
func ReferenceSuffixes(entry ResolvedEntry) []konnectv1alpha1.KonnectConfigStoreSyncReference
ReferenceSuffixes returns the status.references entries for a resolved entry: "<storeKey>/<subfield>" per subfield for Combined mode entries, or "<storeKey>" for Split mode entries.
func ValidateX509KeyPair ¶
ValidateX509KeyPair validates that certPEM and keyPEM form a valid x509 certificate/key pair, following the tls.X509KeyPair pattern used by the ingress-controller translator. It returns the leaf certificate's NotAfter expiry. A missing or unparsable cert or key fails validation: there is no bypass.
Types ¶
type ResolvedEntry ¶
type ResolvedEntry struct {
// StoreKey is the resolved Config Store entry key (explicit or derived).
StoreKey string
// SourceFields are the Secret data keys whose values produce the value.
SourceFields []string
// SubFields are the JSON subfields of the stored value each source field
// maps to. It is empty for Split mode entries (raw values).
SubFields []string
}
ResolvedEntry is one Config Store entry a sync manages, with its resolved store key and the Secret data fields that produce its value.
func ResolveEntries ¶
func ResolveEntries(sync *konnectv1alpha1.KonnectConfigStoreSync) []ResolvedEntry
ResolveEntries computes the set of Config Store entries a sync manages from its spec alone (no Secret or store data needed), applying key derivation where no explicit storeKey is set.
A Split entry's explicit storeKey may still equal another entry's derived key: CRD validation checks uniqueness of explicit storeKeys only, so the caller must reject duplicate resolved StoreKeys itself (see DuplicateStoreKeys).