Misc. general utility functions, not tied to Kubespawner directly

kubespawner.utils.generate_hashed_slug(slug, limit=63, hash_length=6)

Generate a unique name that’s within a certain length limit

Most k8s objects have a 63 char name limit. We wanna be able to compress larger names down to that if required, while still maintaining some amount of legibility about what the objects really are.

If the length of the slug is shorter than the limit - hash_length, we just return slug directly. If not, we truncate the slug to (limit - hash_length) characters, hash the slug and append hash_length characters from the hash to the end of the truncated slug. This ensures that these names are always unique no matter what.