Skip to content

Commit

Permalink
Fix cluster casing (#145)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaeljguarino authored Mar 18, 2024
1 parent 24ede01 commit efeca26
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/manifests/template/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func isTemplated(svc *console.GetServiceDeploymentForAgent_ServiceDeployment) bo
func renderLiquid(input []byte, svc *console.GetServiceDeploymentForAgent_ServiceDeployment) ([]byte, error) {
bindings := map[string]interface{}{
"configuration": configMap(svc),
"cluster": svc.Cluster,
"cluster": clusterConfiguration(svc.Cluster),
"contexts": contexts(svc),
}
return liquidEngine.ParseAndRender(input, bindings)
Expand Down Expand Up @@ -125,3 +125,23 @@ func (r *raw) Render(svc *console.GetServiceDeploymentForAgent_ServiceDeployment
res = newSet.List()
return res, nil
}

func clusterConfiguration(cluster *console.GetServiceDeploymentForAgent_ServiceDeployment_Cluster) map[string]interface{} {
res := map[string]interface{}{
"ID": cluster.ID,
"Self": cluster.Self,
"Handle": cluster.Handle,
"Name": cluster.Name,
"Version": cluster.Version,
"CurrentVersion": cluster.CurrentVersion,
"KasUrl": cluster.KasURL,
}

for k, v := range res {
res[strings.ToLower(k)] = v
}
res["kasUrl"] = cluster.KasURL
res["currentVersion"] = cluster.CurrentVersion

return res
}

0 comments on commit efeca26

Please sign in to comment.