Data Notes

1 min read

Encoding, hashing, and naming utilities.

Reference

NoteSignatureReturns
toBase64stringstring
fromBase64stringstring"" on error
toJSONinterface{}string"{}" on error
sha256sumstringstring (8 hex chars)
slugifystringstring — lowercase, spaces/symbols → dashes, DNS-safe
truncateNames string, n intstring — hard cut, no suffix (for resource names)

Examples

# Secret data: encode value to base64 for Secret.data
data:
  password: "{{ toBase64 .spec.password }}"

# Read a base64-encoded value from a child Secret
- path: dbPassword
  value: "{{ fromBase64 .children.secret.data.password }}"

# Content-addressed resource name — changes when config changes
name: "config-{{ sha256sum .spec.config }}"

# DNS-safe name from user input ("My App / Service" → "my-app-service")
name: "{{ slugify .spec.teamName }}-operator"

# Hard-truncate for k8s resource names (no "..." suffix)
name: "{{ truncateName .spec.projectName 50 }}-deployment"

# Embed structured spec in an annotation
annotations:
  orkestra.io/config: "{{ toJSON .spec.config }}"

truncateName vs truncate

  • truncate (from string notes) appends ... — for human-readable display.
  • truncateName hard-cuts — for Kubernetes resource names where ... is not a valid character.