gsmvalidation

package
v0.0.0-...-0716ad7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CollectionSecretDelimiter is the separator between collection and secret name in GSM
	CollectionSecretDelimiter = "__"

	// Encoding constants for special characters
	DotReplacementString = "--dot--"
	// UnderscorePrefix/Suffix for encoding consecutive underscores
	// __ → --uu--, ___ → --uuu--, etc.
	UnderscorePrefix = "--"
	UnderscoreSuffix = "--"

	CollectionRegex = "^([a-z0-9_-]*[a-z0-9])?$"
	GroupRegex      = `^(--dot--)?[a-zA-Z0-9]+([a-zA-Z0-9_-]*[a-zA-Z0-9]+)?(/[a-zA-Z0-9]+([a-zA-Z0-9_-]*[a-zA-Z0-9]+)?)*$`
	SecretNameRegex = "^[A-Za-z0-9_-]+$"

	// MaxCollectionLength is the maximum length of a collection name
	MaxCollectionLength = 50

	// GcpMaxNameLength is the maximum length for a GSM secret name
	GcpMaxNameLength = 255
)

Variables

This section is empty.

Functions

func DecodeMountFileName

func DecodeMountFileName(encoded string) (string, error)

DecodeMountFileName decodes a GSM-encoded mount filename (field name or `as` alias) and validates it is safe to use as a CSI SecretProviderClass file name.

func DenormalizeName

func DenormalizeName(name string) string

DenormalizeName decodes field names back to their original form. This reverses the encoding done by NormalizeName. Decodes in reverse order of NormalizeName.

func NormalizeName

func NormalizeName(name string) string

NormalizeName replaces forbidden characters in names with safe replacements. This is used when migrating from Vault to GSM to handle special characters. Rules (applied in order):

  1. `__` (2+ consecutive underscores) → `--uu--`, `--uuu--`, etc.
  2. `.` → `--dot--` (dots not allowed in GSM secret names)

Examples:

  • ".dockerconfigjson" → "--dot--dockerconfigjson"
  • "mac_ai__base_dir" → "mac_ai--uu--base_dir"
  • "some___field" → "some--uuu--field"
  • "field.with__both" → "field--dot--with--uu--both"

func ValidateCollectionName

func ValidateCollectionName(collection string) bool

ValidateCollectionName validates a GSM collection name

func ValidateGroupName

func ValidateGroupName(group string) bool

func ValidateMountFileName

func ValidateMountFileName(encoded string) error

ValidateMountFileName validates a GSM-encoded mount filename without returning the decoded value.

func ValidateSecretName

func ValidateSecretName(secretName string) bool

ValidateSecretName validates a GSM secret name

Types

This section is empty.

Jump to

Keyboard shortcuts

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