Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 2.4 KB

builtin_objects.md

File metadata and controls

24 lines (17 loc) · 2.4 KB

Built-in Objects

Objects are passed into a template from the template engine. And your code can pass objects around (we'll see examples when we look at the with and range statements). There are even a few ways to create new objects within your templates, like with the tuple function we'll see later.

Objects can be simple, and have just one value. Or they can contain other objects or functions. For example. the Release object contains several objects (like Release.Name) and the Files object has a few functions.

In the previous section, we use {{.Release.Name}} to insert the name of a release into a template. Release is one of four top-level objects that you can access in your templates.

  • Release: This object describes the release itself. It has several objects inside of it:
    • Release.Name: The release name
    • Release.Time: The time of the release
    • Release.Namespace: The namespace to be released into (if the manifest doesn't override)
    • Release.Service: The name of the releasing service (always Tiller).
  • Values: Values passed into the template from the values.yaml file and from user-supplied files. By default, Values is empty.
  • Chart: The contents of the Chart.yaml file. Any data in Chart.yaml will be accessible here. For example {{.Chart.Name}}-{{.Chart.Version}} will print out the mychart-0.1.0.
  • Files: This provides access to all non-special files in a chart. While you cannot use it to access templates, you can use it to access other files in the chart. See the section Accessing Files for more.
    • Files.Get is a function for getting a file by name (.Files.Get config.ini)
    • Files.GetBytes is a function for getting the contents of a file as an array of bytes instead of as a string. This is useful for things like images.

The values are available to any top-level template. As we will see later, this does not necessarily mean that they will be available everywhere.

The built-in values always begin with a capital letter. This is in keeping with Go's naming convention. When you create your own names, you are free to use a convention that suits your team. Some teams, like the Kubernetes Charts team, choose to use only initial lower case letters in order to distinguish local names from those built-in. In this guide, we follow that convention.