feat(inflection): add dns_1123() for Kubernetes DNS-1123 label normalization#97
Merged
Conversation
…ization Single readable SQL function that lowercases, maps ':' to '--' and '_' to '-', strips invalid chars, trims hyphens, caps at 63 chars (DNS label limit), and drops trailing non-alphanumerics after truncation. Mirrors the TS toK8sName() used to derive Knative/K8s object names.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
inflection.dns_1123(text)— a single, readable SQL function that normalizes an arbitrary string into a Kubernetes DNS-1123 label. Downstream (constructive-db) derives Knative/K8s object names (<slug>-secrets,<slug>-config, service names) and currently hand-builds this exact regexp chain as inline SQL-AST nodes, producing an unreadable nested blob. Consolidating the logic into one named function lets callers emit a singleinflection.dns_1123(slug)call.None of the existing
slugify/pg_slugify/dashedfunctions fit: they keep underscores (\w), have no 63-char label cap, and don't do the:→--namespacing K8s labels need.Examples:
my_service→my-service,org:api→org--api,Hello, World!→helloworld,'a'×80→'a'×63.STRICT IMMUTABLE. 10 case tests added.pgpm packagealso synced the bundle/control/Makefile to the already-current0.30.0(they lagged at0.15.5).Link to Devin session: https://app.devin.ai/sessions/f4e36ac1d5854101838e6825df191c99
Requested by: @pyramation