Hi, Let us understand about Pipeline and default values. Along with functions
The pipeline will be used more frequently to add more value to the calculations..
Say for example, I may want to convert a particular string into an uppercase and then do further processing
by adding double quotes, then I might do some other operation.
And this particular pipeline got derived from the linux concepts.
Let's do some demo and get some better understanding.
Let me get into the templates file, within templates
I'm going to add. Let me open the YAML file.
here I'm going to add couple of more lines.
I am adding a key pipeline and I'm going to have a derivative where
It's going to pick the value from Project code and that will be piped to a function called upper.
So what will happen, the project code will be read from the values file.
And it will be converted into uppercase.
Then the output of it will be piped to another function called quote.
So it's going to quote the output and put that as the final calculated value. The same way I do
have another derivative where I do have a function called
Now, that's going to get the current timestamp
And it's going to pipe it to another function called date.
And that's going to format the date in this particular order.
And the way Go template works for the date formatting is quite different.
So you can verify the same page of sprig functions. Here
A lot more details provided as a part of the date functions.
You can get into this specific link to get more understanding about the usage of date formatting within
go templates and output of it will be quoted.
So here the current timestamp will be formatted in this particular structure and output will be enclosed
within double quotes. So I'm storing the value
Let me go ahead and do a dry run.
Let me get into the location so that I can access the chart resources. Let me do the dry run.
Here, say for example, the pipeline, what it did
It took the project code converted that into uppercase and then enclosed within the double quotes the
same way the next one
It took the current timestamp converted into the structure that I had defined and enclosed within the double quotes.
So this is one of the very useful functions when we are moving on to the condition, verifications or
looping, lot more places this will be very, very useful.
And to apply the logical operators this will be very useful.
Along with this, we need to have understanding on the default value as well.
Whenever we do some computation, we may not get the value
Or that may not be available from the place where we are calculating the value.
So we need to provide some default value so that it can be replaced.
And the value is getting calculated to provide it to the template.
Let me go ahead and add some additional details to the templates. Let me edit
the yaml file. Here I'm going to provide another line.
where I'm going to have a derivative.
So it's going to pick the values contact from the values file.
And I have not added the contact within the values file anyway we can go ahead and verify.
And in case, if the value is not calculated or it is not derived from the values file, it is going
to use this value as the default one.
And it is going to add a code to it. For confirmation
Let me go ahead and check the values yaml file as well. Here
I do not have value for contact.
Now, let me go ahead and do a dry run with this particular chart resources.
It did not find the value.
So it replaced the default value that we had provided.
Now we can confirm this by setting the value as a part of the dry run so that we can check whether it
is replacing the default value or not.
Now, I'm going to run the dry run on the same chart resources I'm passing the contact value where
I'm going to have 8888 in the end.
So within the calculated value, it replaced the value that we provided as part of the command prompt
using the argument --set. So in a quick summary we have seen how to use the pipeline and the default
value within the templates.