1
00:00:00,000 --> 00:00:11,900
Hi, Now let us understand how to have the template as a part of a separate file and include in another template.

2
00:00:11,900 --> 00:00:14,700
Let me get into the project. As a part of templates

3
00:00:14,700 --> 00:00:17,266
I'm going to create a file.

4
00:00:17,266 --> 00:00:22,766
With prefix underscore, all the helper files will be having the prefix underscore

5
00:00:22,766 --> 00:00:26,366
So I'm going to create a file.

6
00:00:26,366 --> 00:00:32,732
with the name underscore helpers.tpl. As a part of this I'm going to include the template

7
00:00:32,732 --> 00:00:37,466
content that we had as a part of the main file.

8
00:00:37,466 --> 00:00:40,632
So it's going to have a name, mychart.system labels.

9
00:00:40,633 --> 00:00:47,466
And the alignment within the template is important than how we are going to include within the main file.

10
00:00:47,466 --> 00:00:52,599
Let me go ahead and edit the main file.

11
00:00:52,600 --> 00:00:58,600
This particular content is not required as it is already included within the main file.

12
00:00:58,600 --> 00:01:03,233
And I'm going to include the template with the name mychart.system labels.

13
00:01:03,233 --> 00:01:06,599
It also proves the name of the template is universal.

14
00:01:06,600 --> 00:01:11,966
In case if I have any template with duplicate names, the one that is getting loaded latest will

15
00:01:11,966 --> 00:01:20,199
be used. So always it is recommended to follow the name space structure and avoid duplicates of the template file names.

16
00:01:20,200 --> 00:01:26,833
So what we have done, we created another file underscore helpers.tpl and included the template content within it.

17
00:01:26,833 --> 00:01:31,933
And the same template is referred within this particular file config map.yaml file.

18
00:01:31,933 --> 00:01:35,999
As we discussed earlier, the template folders can have three type of files.

19
00:01:36,000 --> 00:01:42,633
One is the yaml files, which are going to have manifest for kubernetes and notes.txt file which will

20
00:01:42,633 --> 00:01:47,033
have information about this particular charts and the resources.

21
00:01:47,033 --> 00:01:49,666
We will have a detailed discussion about the notes files

22
00:01:49,666 --> 00:01:56,099
And helpers file will have all the helpers template which will get included in the main template.

23
00:01:56,100 --> 00:02:01,400
Now, let me go ahead and do a dry run.

24
00:02:01,400 --> 00:02:04,833
So the labels were included as a part of the main template.

25
00:02:04,833 --> 00:02:07,766
This is another way of including the template.

26
00:02:07,766 --> 00:02:09,499
And this is what is recommended where

27
00:02:09,500 --> 00:02:15,433
I can have the atomic content of different templates in the helper template file and include in the

28
00:02:15,433 --> 00:02:18,199
main template files. Now let us understand

29
00:02:18,200 --> 00:02:23,000
What if we include the built-In global objects as a part of the templates and how the scope will

30
00:02:23,000 --> 00:02:26,233
get transferred into the templates.

31
00:02:26,233 --> 00:02:30,199
Now I'm going to edit the same template file.

32
00:02:30,200 --> 00:02:36,200
And as a part of the labels, I am going to include few builtin objects. So I'm including the builtin

33
00:02:36,200 --> 00:02:41,433
objects like release.name, chart.appversion, release.service

34
00:02:41,433 --> 00:02:46,533
So it should pick this particular global builtin objects and print it over here.

35
00:02:46,533 --> 00:02:50,299
That's going to be a surprise where the values will be blank.

36
00:02:50,300 --> 00:02:58,166
Let's go ahead and do a dry run of this particular chart.

37
00:02:58,166 --> 00:03:01,099
I'm not having any value for the builtin objects.

38
00:03:01,100 --> 00:03:07,066
The reason, because the templates where I'm going to use I need to pass the context so that that

39
00:03:07,066 --> 00:03:12,832
can be used as a scope and that can be passed as a dot or dollar.

40
00:03:12,833 --> 00:03:21,133
Lets try out both the options. Let me edit the template, so when the template is getting invoked

41
00:03:21,133 --> 00:03:26,966
I need to pass the scope as well that can be passed as a dot.

42
00:03:26,966 --> 00:03:31,932
That means the current templates scope will get passed to this particular template

43
00:03:31,933 --> 00:03:37,799
And this particular template will have the builtin objects so that it can pass and the values would

44
00:03:37,800 --> 00:03:43,133
get printed. Let me do the dry run.

45
00:03:43,133 --> 00:03:48,266
Yes, it's able to get the values. Instead of dot I can use the dollar as well.

46
00:03:48,266 --> 00:03:50,199
Dollar is what more recommended.

47
00:03:50,200 --> 00:03:55,066
Let's try out that particular option as well.

48
00:03:55,066 --> 00:03:58,032
So while invoking the template instead of dot I can use the

49
00:03:58,033 --> 00:04:06,099
dollar as well. Now, let me go ahead and do the dry run.

50
00:04:06,100 --> 00:04:08,833
Now also I'm able to get the global builtin objects.

51
00:04:08,833 --> 00:04:12,299
So that means whenever I'm going to use the named templates

52
00:04:12,300 --> 00:04:17,132
I need to pass the scope if I have to use any of the global builtin objects.

