Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions charts/substrate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,64 @@ Qualified resource name for a chart component.
Usage:
{{ include "substrate.fullname" (list "ate-api-server" .) }}

When the release name equals the chart name (the canonical render in
When the release name is "substrate" (the canonical render in
hack/render-manifests.sh — `helm template substrate charts/substrate`), this
returns the bare component name, so the generated manifests/ate-install/
files keep their historical names ("ate-api-server", "ate-controller", ...).

Otherwise resources are prefixed with the release name in the standard Helm
style ("foo-ate-api-server", ...) so multiple releases coexist without
colliding.

The check is on the literal release name "substrate" rather than
$ctx.Chart.Name so this helper is context-safe: a parent chart can invoke it
with its own `.` (where .Chart.Name is the parent, not "substrate") and still
get the same prefixed name that this subchart's own templates render.
*/}}
{{- define "substrate.fullname" -}}
{{- $name := index . 0 -}}
{{- $ctx := index . 1 -}}
{{- if eq $ctx.Release.Name $ctx.Chart.Name -}}
{{- if eq $ctx.Release.Name "substrate" -}}
{{- $name -}}
{{- else -}}
{{- printf "%s-%s" $ctx.Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
ServiceAccount name of ate-api-server, as this chart creates it. Parent
charts that need to bind additional Roles to this SA (e.g. env-source
Secret/ConfigMap reads for ActorTemplate resolution) should reference this
helper instead of hardcoding "ate-api-server":

{{ include "substrate.ateApiServer.serviceAccountName" . }}
*/}}
{{- define "substrate.ateApiServer.serviceAccountName" -}}
{{- include "substrate.fullname" (list "ate-api-server" .) -}}
{{- end -}}

{{/*
gRPC endpoint that clients dial to reach ate-api-server. dns:/// scheme +
release-prefixed Service name + release namespace + :443. Suitable for
consumption as ATE_API_ENDPOINT / --ateapi-address:

{{ include "substrate.ateApi.endpoint" . }}
-> dns:///<release>-api.<namespace>.svc:443
*/}}
{{- define "substrate.ateApi.endpoint" -}}
{{- printf "dns:///%s.%s.svc:443" (include "substrate.fullname" (list "api" .)) .Release.Namespace -}}
{{- end -}}

{{/*
Plaintext HTTP URL that clients use to reach atenet-router.

{{ include "substrate.atenetRouter.url" . }}
-> http://<release>-atenet-router.<namespace>.svc:80
*/}}
{{- define "substrate.atenetRouter.url" -}}
{{- printf "http://%s.%s.svc:80" (include "substrate.fullname" (list "atenet-router" .)) .Release.Namespace -}}
{{- end -}}

{{/*
Build an image reference for a substrate component binary.

Expand Down
Loading