0Pricing
Helm Academy · Lesson

String Helpers from the Sprig Library

upper, trunc, replace, and friends.

String Helpers from the Sprig Library is a free Helm Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Helm Bundles Sprig

Beyond Go's built-ins, Helm ships the Sprig library, giving your templates dozens of ready-made string helpers. 📚

Changing Case

Use upper and lower to normalize case. They are perfect for forcing labels or names into a consistent form.

{{ .Values.name | upper }}

Title Casing

The title helper capitalizes the first letter of each word, handy for display strings rendered into your manifests.

{{ "hello world" | title }}

Cutting Length with trunc

Kubernetes names cap at 63 characters. The trunc helper shortens a string so generated names stay within that limit.

{{ .Values.name | trunc 63 }}

Stripping Trailing Dashes

After truncating, pair trimSuffix with a dash to avoid a name ending in a stray hyphen, which Kubernetes rejects.

{{ .Values.name | trunc 63 | trimSuffix "-" }}

Swapping Substrings

The replace helper swaps every occurrence of one substring for another, useful for sanitizing user-supplied values.

{{ .Values.name | replace "_" "-" }}

Trimming Whitespace

Use trim to remove leading and trailing whitespace, cleaning up values that arrive with stray spaces or newlines.

{{ .Values.token | trim }}

Checking Prefixes

The hasPrefix helper returns true when a string starts with a given value, great for conditional logic in templates.

{{ if hasPrefix "v" .Values.tag }}semver{{ end }}

Joining and Splitting

Turn a list into a string with join, or break a string into parts with splitList. Both bridge lists and strings.

{{ .Values.hosts | join "," }}

Composing String Helpers

These helpers chain beautifully. A single pipeline can lowercase, truncate, then trim a name into a valid resource label.

{{ .Values.name | lower | trunc 53 | trimSuffix "-" }}

Find More in the Docs

Sprig offers far more than these. When you need a transform, check the Sprig docs before writing custom logic.

Quick Check

Which helper keeps a generated name under Kubernetes' 63-character limit?

Recap

You explored Sprig string helpers like upper, trunc, replace, and trim. Chain them to shape values into valid YAML. 🎉

Frequently asked questions

Is the “String Helpers from the Sprig Library” lesson free?

Yes — the full text of “String Helpers from the Sprig Library” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.

What will I learn in “String Helpers from the Sprig Library”?

upper, trunc, replace, and friends. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Helm Academy?

No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “String Helpers from the Sprig Library” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Helm Academy lesson?

Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Piping Values Through Functions
  2. default, required, and quote
  3. String Helpers from the Sprig Library
  4. Encoding with b64enc, toYaml, and indent
← Back to Helm Academy