Skip to content

Commit efeca26

Browse files
Fix cluster casing (#145)
We were previously just referencing the go struct for a cluster, which bleeds out go's atypical casing for struct keys. This will coerce things to something a bit more typical for end users in templates.
1 parent 24ede01 commit efeca26

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

pkg/manifests/template/raw.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func isTemplated(svc *console.GetServiceDeploymentForAgent_ServiceDeployment) bo
6060
func renderLiquid(input []byte, svc *console.GetServiceDeploymentForAgent_ServiceDeployment) ([]byte, error) {
6161
bindings := map[string]interface{}{
6262
"configuration": configMap(svc),
63-
"cluster": svc.Cluster,
63+
"cluster": clusterConfiguration(svc.Cluster),
6464
"contexts": contexts(svc),
6565
}
6666
return liquidEngine.ParseAndRender(input, bindings)
@@ -125,3 +125,23 @@ func (r *raw) Render(svc *console.GetServiceDeploymentForAgent_ServiceDeployment
125125
res = newSet.List()
126126
return res, nil
127127
}
128+
129+
func clusterConfiguration(cluster *console.GetServiceDeploymentForAgent_ServiceDeployment_Cluster) map[string]interface{} {
130+
res := map[string]interface{}{
131+
"ID": cluster.ID,
132+
"Self": cluster.Self,
133+
"Handle": cluster.Handle,
134+
"Name": cluster.Name,
135+
"Version": cluster.Version,
136+
"CurrentVersion": cluster.CurrentVersion,
137+
"KasUrl": cluster.KasURL,
138+
}
139+
140+
for k, v := range res {
141+
res[strings.ToLower(k)] = v
142+
}
143+
res["kasUrl"] = cluster.KasURL
144+
res["currentVersion"] = cluster.CurrentVersion
145+
146+
return res
147+
}

0 commit comments

Comments
 (0)