Are Helm variables case insensitive? (The templates seem to be.) - kubernetes-helm

I am trying to debug one of my Helm charts and I noticed that the app.kubernetes.io/version label is created using the following code (in _helpers.tpl):
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
But the actual variable is called appVersion. Similar inconsistencies exist with version and name. The use of them is using PascalCase, but the definition is using camelCase. I tried to google it, but can't find any info on it.
Are Helm variables really case insensitive? Or is there some kind of conversion going on behind the scenes.

The fields in the built-in objects are generally capitalized. That documentation also includes an example using {{ .Chart.Name }}-{{ .Chart.Version }}. Even though .Chart contains the contents of the chart.yaml file, its fields follow this convention.
Field access is case-sensitive and if you reference .Chart.appVersion you should get an error.
At an implementation level, the Go template . operator can either navigate a Go object tree or a Go map. The top-level object is a mix of maps and objects. .Values is an unstructured map; a release can include any values it wants in essentially any YAML layout. .Release turns out to be a map too, but with fixed known keys.
.Chart is a chart.Metadata object (not the parsed YAML directly but an object form of it). Its fields are visible to the template engine. Go's rule is that structure fields that begin with capital letters are visible, and that capitalization carries through back to the template engine.

Related

CSV Data in jekyll: how to sort and display data according to "Publication year"

I am trying to work on a simple workflow to sort out my publications csv to a list in my jekyll-based website.
This is my references.csv extracted from referencing software Mendeley and converted from bib to csv using online converter. I want to place this in my _data folder and make a list of publications in the page on jekyll website hosted on github. The sampe data is shown below:
"Item type","Authors","Title","Journal","Publication year","Volume","Issue","Pages","Publisher","Date published","ISSN","URLs","DOI","PMID","Abstract","Keywords"
"Book","Wilden H","PCI design handbook: Precast and prestressed concrete","","2017","","","","Precast/Prestressed Concrete Institute Wakefield, MA, USA","2017","","","","","",""
"Journal Article","Nanni A,Di Ludovico M,Parretti R","Shear strengthening of a PC bridge girder with NSM CFRP rectangular bars","Advances in Structural Engineering","2004","7","4","297-309","SAGE PublicationsSage UK: London, England","2004-11","1369-4332","https://journals.sagepub.com/doi/10.1260/1369433041653570;http://dx.doi.org/10.1260/1369433041653570","10.1260/1369433041653570","","trimmed down abstract","keyword 1"
"Journal Article","Di B,Wang J,Li H,Zheng J,Zheng Y,Song G","Investigation of Bonding Behavior of FRP and Steel Bars in Self-Compacting Concrete Structures Using Acoustic Emission Method","Sensors 2019, Vol. 19, Page 159","2019","19","1","159","Multidisciplinary Digital Publishing Institute","2019-01","1424-8220","http://dx.doi.org/10.3390/S19010159;https://www.ncbi.nlm.nih.gov/pubmed/30621189","10.3390/S19010159","30621189","To extend ","FRP,acoustic emission,bonding,compacting concrete,out test,pull,self"
"Journal Article","Crivelli D,Bland S","Structural health monitoring via acoustic emission","Reinforced Plastics","2016","60","6","390-392","Elsevier Ltd","2016-11","0034-3617","http://dx.doi.org/10.1016/j.repl.2015.05.004","10.1016/j.repl.2015.05.004","","Reinforced Plastics spoke to Dr Davide Crivelli from the Politecnico di Milano about new methods for detecting damage in composites.",""
"Journal Article","Tonelli D,Luchetta M,Rossi F,Migliorino P,Zonta D","Structural health monitoring based on acoustic emissions: Validation on a prestressed concrete bridge tested to failure","Sensors (Switzerland)","2020","20","24","1-20","Multidisciplinary Digital Publishing Institute","2020-12","1424-8220","http://dx.doi.org/10.3390/s20247272;https://www.ncbi.nlm.nih.gov/pubmed/33352961","10.3390/s20247272","33352961","very small abstract","AE"
Now, I want to make the list from these data as a citation data without getting into complexities of _includes. I want to keep it simple in a separate "Publications" page.
For example, I used the following code
{% assign cards = site.data.references | sort: 'Publication_year' | 'reverse' %}
{% for card in cards %}
<ul>
<li>{{ card.Publication year }} {{ card.Title }} {{ card.Publication }} </li>
<ul> {{ card.Authors }} {{ card.Authors }} </ul>
</ul>
{% endfor %}
In the code, when I use the heading in csv as "Year" and then sort using sort: 'Year' | 'reverse' %,it works. Maybe, there is a different way to write it for "two-worded" headings, as I think the card.Publication year won't work. i have spent a lot of time on this and I think I need to just use the code once and then just work with the csv file only.
The output I intend to only pick up the Journal Article from the Item type and prepare a list with the following information with items shown in the following:
[Publication year][title][Journal]
[Authors]
Also, I tried italisizing the text in one of the items, it should work like {{ __card.Publication year__ }} but it does not. I also read somewhere that the csv encoding doesn't allow to extract the first column due to some BOM or UTF-8 something encoding. But I want to filter using the item type.
ps I have tried to compromise with another simplified code with headings same as this, but the google scholar exported csv has ; as delimiters and while using card.Authors does not work to call the data.
I apologize I am not at all familiar with this and I am struggling with using this syntax. However, I foresee that if the code works, it will make my life easier. I would really appreciate your help. I apologize for any lack of proper jargon while explaining the problem.
Thank you in advance.
I tried to display the data from csv data file on the website but some values are missing. I cannot figure out the solution
You're on the right track but you are incorrectly referencing the CSV file column. Since "Publication year" is a two-worded heading, you need to reference it using underscores instead of spaces.
Try changing this line:
{% assign cards = site.data.references | sort: 'Publication_year' | 'reverse' %}
You can use sort_by instead of sort and provide 'Publication_year' as an argument.
{% assign cards = site.data.references | sort_by: 'Publication_year' | reverse %}
When you reference the column in the for loop, you should also use underscores:
<li>{{ card.Publication_year }} {{ card.Title }} {{ card.Journal }} </li>

Grafana Alert Templating

I am struggling to include values into my alerting template
(Using Grafana 9.03 with classic condition alerting)
Query
Alert Evaluation
I tried to use {{ $values.B0 }} which works but only displaying the value. I want to use the Tag "Limit" for example "ImportStatNSC4903"
I did some more tries with:
{{ $values.B0.Limit }}
{{ $values.B0.labels }}
{{ $labels }}
Any ideas what I am doing wrong?
I am struggling to include values into my alerting template. I want a summery that tells me clearly why this alert was triggered
For example:
Limit ImportStatNSC4903 is outside the defined Boundaries

Where can I find all {{ codes }} that can be used in pages/blocks/cms content?

For example I know of
{{block class="Magento\Cms\Block\Block" block_id="block_identifier"}}
But where can I find documentation on all available features of this template language?
What other arguments can I use for {{ block }} etc.
The official Magento 2 documentation doesn't specify this. But, I think you can typically access all public fields of the base block class. If you are on a dev environment, their might be an error output even, if you use a wrong attribute. That error output probably shows, which attributes you are allowed to use.
The class responsible for parsing the {{ }} directives in
CMS Blocks and Pages is \Magento\Cms\Model\Template\Filter
which extends \Magento\Email\Model\Template\Filter.
In the latter the following directives are implemented:
block
layout
view
media
store
trans
var
protocol
config
customvar
css
inlinecss
widget
The last one is provided by the Widget module.
You can find some more info in this section the official Magento docs

form_widget : Add classes to existing classes

I want to add classes to existing classes with twig, when invoking the form_widget()-function, so I'd like to merge them. But when I use
{{ form_widget(form.field1), {'attr': {'class': 'foo'}} }}
on an object that already has some classes attached to it by the controller, it doesn't add the class(es), but replaces them. According to the documantation this would
render a widget, but add a "foo" class to it
But the formulation isn't clear about, if the classes are really "added" or if they are replaced.
It seems that I would need to have a way to access the existing attributes/classes and merge them together with the ones I want to add. How can I accomplish this?
You might use form.field1.vars.attr.class and something like str1 ~ str2 to merge the already given classes and your new ones.
Putting it all together you get:
{{ form_widget(form.field1), {'attr': {'class': form.field1.vars.attr.class ~ foo'}} }}
this works and solves your problem. Some background:
According to the symfony documentation form.field1.vars.attr is a key based array, with a class-key.
So you can access all existing classes in this way.

Explicitly print CSRF token field instead of form_rest(form)?

How can I explicitly print CSRF field instead of using {{ form_rest(form) }}?
I need this because I'm going to hide/show some fields based on conditions, however {{ form_rest(form) }} is going to print all of the remaining fields (which is what I'd like to avoid).
It can be done this way:
{{ form_widget(form._token) }}
Also you might want to consider adding fields conditionally in your form type instead of making that kind of decisions in a template.