slice = array/list → index slice number
dict = map/dictionary → index dict key
thats Yaml syntax - lets convert that to JSON and you may see it easier
{ <-- that opens a map (key : value)
"release": { <- release is a map holding four keys
"app": "testApp",
"channel": "Stable",
"version": "2.7.3+6"
},
"release-notes": "", <-- thats a simple key value pair
"release-date": "2024-11-15T07:00:59Z",
"bom": [ <-- starting a list/array of map elements
{ <- this is the first element bom[0] (index bom 0)
"helm-chart-name": "ingress-nginx",
"helm-chart-version": "4.10.0"
},
{ <- this is the second element bom[1] (index bom 1)
"helm-chart-name": "cert-manager",
"helm-chart-version": "v1.14.4"
}
]
}
So now to the data:
- site.Data is a map (so a key value pair)
- the keys are the filenames without extension
- the value is the content of the file
to investigate site.Data structure you can use
{{ highlight (transform.Remarshal "YAML" site.Data) "YAML" }}
{{ highlight (transform.Remarshal "JSON" site.Data) "JSON" }}
JSON
{
"myfile": {
"bom": [
{
"helm-chart-name": "ingress-nginx",
"helm-chart-version": "4.10.0"
},
{
"helm-chart-name": "cert-manager",
"helm-chart-version": "v1.14.4"
}
],
"dots": [
{
"helm.chart.name": "ingress-nginx",
"helm.chart.version": "4.10.0"
},
{
"helm.chart.name": "cert-manager",
"helm.chart.version": "v1.14.4"
}
],
"release": {
"app": "testApp",
"channel": "Stable",
"version": "2.7.3+6"
},
"release-date": "2024-11-15T07:00:59Z",
"release-notes": ""
},
"product-2-7-3+6": {
"bom": [
{
"helm-chart-name": "ingress-nginx",
"helm-chart-version": "4.10.0"
},
{
"helm-chart-name": "cert-manager",
"helm-chart-version": "v1.14.4"
}
],
"dots": [
{
"helm.chart.name": "ingress-nginx",
"helm.chart.version": "4.10.0"
},
{
"helm.chart.name": "cert-manager",
"helm.chart.version": "v1.14.4"
}
],
"release": {
"app": "testApp",
"channel": "Stable",
"version": "2.7.3+6"
},
"release-date": "2024-11-15T07:00:59Z",
"release-notes": ""
},
"product-2.6.7+3": {
"bom": [
{
"helm-chart-name": "ingress-nginx",
"helm-chart-version": "4.10.0"
},
{
"helm-chart-name": "cert-manager",
"helm-chart-version": "v1.14.4"
}
],
"dots": [
{
"helm.chart.name": "ingress-nginx",
"helm.chart.version": "4.10.0"
},
{
"helm.chart.name": "cert-manager",
"helm.chart.version": "v1.14.4"
}
],
"release": {
"app": "testApp",
"channel": "Stable",
"version": "2.7.3+6"
},
"release-date": "2024-11-15T07:00:59Z",
"release-notes": ""
}
}
Yaml
myfile:
bom:
- helm-chart-name: ingress-nginx
helm-chart-version: 4.10.0
- helm-chart-name: cert-manager
helm-chart-version: v1.14.4
dots:
- helm.chart.name: ingress-nginx
helm.chart.version: 4.10.0
- helm.chart.name: cert-manager
helm.chart.version: v1.14.4
release:
app: testApp
channel: Stable
version: 2.7.3+6
release-date: "2024-11-15T07:00:59Z"
release-notes: ""
product-2-7-3+6:
bom:
- helm-chart-name: ingress-nginx
helm-chart-version: 4.10.0
- helm-chart-name: cert-manager
helm-chart-version: v1.14.4
dots:
- helm.chart.name: ingress-nginx
helm.chart.version: 4.10.0
- helm.chart.name: cert-manager
helm.chart.version: v1.14.4
release:
app: testApp
channel: Stable
version: 2.7.3+6
release-date: "2024-11-15T07:00:59Z"
release-notes: ""
product-2.6.7+3:
bom:
- helm-chart-name: ingress-nginx
helm-chart-version: 4.10.0
- helm-chart-name: cert-manager
helm-chart-version: v1.14.4
dots:
- helm.chart.name: ingress-nginx
helm.chart.version: 4.10.0
- helm.chart.name: cert-manager
helm.chart.version: v1.14.4
release:
app: testApp
channel: Stable
version: 2.7.3+6
release-date: "2024-11-15T07:00:59Z"
release-notes: ""
for other objects while developing you may use debug.Dump (read the docs about limitations)
{{ highlight (debug.Dump $) "JSON" }}
p.s. instead of highlight
use warnf
to output to the console without rendering it to the page.