Move the real player authority to server
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Add rust bindings for the server player controller
- Implement reconciliation loop for checking the player state
- Place spawners on the test map
- Add Containerfile and helm chart
This commit is contained in:
2025-01-29 12:25:26 +01:00
parent 523900cc82
commit dfe888a918
94 changed files with 3002 additions and 144 deletions

View File

@ -0,0 +1,17 @@
{{/*
* CRDs should always be managed as a separate chart
* They must be written to the ./crd folder and then
* they will be read by the .Files helm feature
*/}}
{{- define "lib.component.crd" -}} {{- /* define[0] */ -}}
{{-
$metadata := include "lib.metadata"
(dict "ctx" $ "annotations" .Values.workload.annotations)
}}
{{ $currentScope := .}}
{{ range $path, $_ := .Files.Glob "**.yaml" }}
{{- with $currentScope}}
{{ .Files.Get $path }}
{{- end }}
{{ end }}
{{- end -}} {{- /* define[0] */ -}}

View File

@ -0,0 +1,46 @@
{{/*
* This component should make it easier to create sets
* of environment variables via configmaps and secrets
*/}}
{{- define "lib.component.environment" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- range $k, $v := .ctx.Values.config.env }} {{- /* range[0] */}}
{{- $customName := include "lib.component.env.name" (dict "ctx" $.ctx "name" $k) }}
{{- if $v.enabled }} {{- /* if[0] */}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" $.ctx
"global" ($.ctx.Values.metadata).labels
"local" ($v.metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" $.ctx
"name" $customName
"annotations" ($v.metadata).annotations
"labels" $labels
)
}}
{{- $data := dict -}}
{{- range $key, $value := $v.data }} {{- /* range[1] */}}
{{- if not (has $key ($v.remove)) }} {{- /* if[1] */}}
{{- $_ := set $data $key (tpl (toString $value) $.ctx) }}
{{- end }} {{- /* /if[1] */}}
{{- end }} {{- /* /range[1] */}}
{{- if $v.sensitive }} {{- /* if[1] */}}
{{ include "lib.core.secret" (dict "ctx" $ "metadata" $metadata "data" $data) }}
{{- else }}
{{ include "lib.core.configmap" (dict "ctx" $ "metadata" $metadata "data" $data) }}
{{- end -}} {{- /* /if[1] */}}
{{- end }} {{- /* /if[0] */}}
{{- end }} {{- /* /range[0] */}}
{{- end -}} {{- /* /define[0] */ -}}
{{- define "lib.component.env.name" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}}
{{ printf "%s-%s-env" .ctx.Release.Name .name }}
{{- end -}} {{- /* /define[0] */ -}}

View File

@ -0,0 +1,16 @@
{{- define "lib.component.templates" }} {{- /* define[0] */}}
{{- include "lib.error.noCtx" . -}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" .ctx
"global" ((.ctx.Values).metadata).labels
)
}}
{{- with (.ctx.Values.extra).templates }} {{- /* with[1] */}}
{{- range . }} {{- /* range[2] */}}
---
{{- tpl . $.ctx | indent 0 }}
{{- end }} {{- /* /range[2] */}}
{{- end }} {{- /* /with[1] */}}
{{- end }} {{- /* /define[0] */}}

View File

@ -0,0 +1,64 @@
{{/*
* This component should make it easier to create sets
* of environment variables via configmaps and secrets
*/}}
{{- define "lib.component.files" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- range $k, $v := .ctx.Values.config.files }} {{- /* range[0] */}}
{{- $customName := include "lib.component.file.name" (dict "ctx" $.ctx "name" $k) }}
{{- if $v.enabled }} {{- /* if[0] */}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" $.ctx
"global" ($.ctx.Values.metadata).labels
"local" ($v.metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" $.ctx
"name" $customName
"annotations" $v.annotations
"labels" $labels
)
}}
{{- $entries := dict -}}
{{- range $key, $value := $v.entries }} {{- /* range[1] */}}
{{- if not (has $key ($v.remove)) }} {{- /* if[1] */}}
{{- $data := $value.data }}
{{- if and (kindIs "string" $data) ($value.convertTo) }} {{- /* if[2] */}}
{{- fail "convering is only possible for plain yaml, strings are not supported" -}}
{{- end }} {{- /* /if[2] */}}
{{- if $value.convertTo -}} {{- /* if[2] */ -}}
{{- if eq $value.convertTo "json" }} {{- /* if[3] */}}
{{- $data = include "lib.helpers.convertToJson" $data -}}
{{- else if eq $value.convertTo "toml" -}}
{{- $data = include "lib.helpers.convertToToml" $data -}}
{{- else if eq $value.convertTo "yaml" -}}
{{- $data = include "lib.helpers.convertToYaml" $data -}}
{{- else -}}
{{- fail (printf "converion to %s is not supported yet" $value.convertTo) -}}
{{- end -}} {{- /* /if[3] */ -}}
{{- end -}} {{- /* /if[2] */ -}}
{{- if not (kindIs "string" $data) -}}
{{- fail (printf "it must be a string, but it's a %s: %v" (kindOf $data) $data) -}}
{{- end -}}
{{- $_ := set $entries $key (tpl $data $.ctx) }}
{{- end }} {{- /* /if[1] */}}
{{- end }} {{- /* /range[1] */}}
{{- if $v.sensitive }} {{- /* if[1] */}}
{{ include "lib.core.secret" (dict "ctx" $ "metadata" $metadata "data" $entries) }}
{{- else }}
{{ include "lib.core.configmap" (dict "ctx" $ "metadata" $metadata "data" $entries) }}
{{- end -}} {{- /* /if[1] */}}
{{- end }} {{- /* /if[0] */}}
{{- end }} {{- /* /range[0] */}}
{{- end -}} {{- /* /define[0] */ -}}
{{- define "lib.component.file.name" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}}
{{ printf "%s-%s-file" .ctx.Release.Name .name }}
{{- end -}} {{- /* /define[0] */ -}}

View File

@ -0,0 +1,33 @@
{{- define "lib.component.ingress" }}
{{- range $k, $v := .ctx.Values.ingress }}
{{- $customName := include "lib.component.ingress.name" (dict "ctx" $.ctx "name" $k) }}
{{- if $v.enabled }} {{- /* if[0] */}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" $.ctx
"global" ($.ctx.Values.metadata).labels
"local" ($v.metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" $.ctx
"annotations" ($v.metadata).annotations
"labels" $labels
"name" $customName
)
}}
{{- $spec := $v -}}
{{- $_ := unset $spec "enabled" -}}
{{ include "lib.core.ingress" (dict "ctx" $.ctx "metadata" $metadata "spec" $spec ) }}
{{- end }}
{{- end }}
{{- end }}
{{- define "lib.component.ingress.name" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}}
{{ printf "%s-%s" .ctx.Release.Name .name }}
{{- end -}} {{- /* /define[0] */ -}}

View File

@ -0,0 +1,42 @@
{{/*
* This component should make it easier to create pvc
*/}}
{{- define "lib.component.service" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- range $k, $v := .ctx.Values.services }} {{- /* range[1] */}}
{{- $customName := include "lib.component.service.name" (dict "ctx" $.ctx "name" $k) }}
{{- if $v.enabled }} {{- /* if[2] */}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" $.ctx
"global" ($.ctx.Values.metadata).labels
"local" ($v.metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" $.ctx
"name" $customName
"annotations" ($v.metadata).annotations
"labels" $labels
)
}}
{{ $spec := $v }}
{{- if not $spec.type -}}
{{- set $spec "type" "ClusterIP" -}}
{{- end }}
{{
include "lib.core.service"
(dict "ctx" $.ctx "metadata" $metadata "spec" $spec)
}}
{{- end }}
{{- end }}
{{- end -}} {{- /* /define[0] */ -}}
{{- define "lib.component.service.name" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}}
{{ printf "%s-%s" .ctx.Release.Name .name }}
{{- end -}} {{- /* /define[0] */ -}}

View File

@ -0,0 +1,35 @@
{{/*
* This component should make it easier to create pvc
*/}}
{{- define "lib.component.storage" -}}
{{- include "lib.error.noCtx" . -}}
{{- range $k, $v := .ctx.Values.storage }}
{{- $customName := include "lib.component.storage.name" (dict "ctx" $.ctx "name" $k) }}
{{- if $v.enabled }} {{- /* if[0] */}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" $.ctx
"global" ($.ctx.Values.metadata).labels
"local" ($v.metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" $.ctx
"annotations" ($v.metadata).annotations
"labels" $labels
"name" $customName
)
}}
{{ include "lib.core.pvc" (dict "metadata" $metadata "spec" $v) }}
{{- end }} {{- /* /if[0] */}}
{{- end }}
{{- end -}}
{{- define "lib.component.storage.name" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}}
{{ printf "%s-%s-storage" .ctx.Release.Name .name }}
{{- end -}} {{- /* /define[0] */ -}}

View File

@ -0,0 +1,65 @@
{{- define "lib.component.workload.allowed" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{ index .ctx.Chart.Annotations "allowed_workload_kinds" }}
{{- end -}} {{- /* /define[0] */ -}}
{{- define "lib.component.workload" -}} {{- /* define[0] */ -}}
{{- include "lib.error.noCtx" . -}}
{{-
$labels := include "lib.metadata.mergeLabels"
(dict
"ctx" .ctx
"global" ((.ctx.Values).metadata).labels
"local" (((.ctx.Values.base).workload).metadata).labels
)
}}
{{-
$metadata := include "lib.metadata"
(dict
"ctx" .ctx
"annotations" (((.ctx.Values.base).workload).metadata).annotations
"labels" $labels
)
}}
{{-
$securityContext := include "lib.core.pod.securityContext"
(dict
"securityContext" .ctx.Values.base.workload.securityContext
)
}}
{{
$containers := include "lib.core.pod.containers"
(dict
"ctx" .ctx
"containers" .ctx.Values.base.workload.containers
)
}}
{{
$volumes := include "lib.core.pod.volumes"
(dict
"ctx" .ctx
"files" (.ctx.Values.config).files
"storage" .ctx.Values.storage
"extraVolumes" .ctx.Values.extraVolumes
)
}}
{{- if eq .ctx.Values.base.workload.kind "Deployment" -}} {{- /* if[0] */ -}}
{{- if contains .ctx.Values.base.workload.kind (include "lib.component.workload.allowed" (dict "ctx" .ctx)) }}{{- /* if[0] */ -}}
{{-
include "lib.core.deployment"
(dict
"ctx" .ctx
"metadata" $metadata
"securityContext" $securityContext
"containers" $containers
"volumes" $volumes
)
}}
{{- else -}}
{{- fail (printf "workload kind is not allowed: %s" .ctx.Values.base.workload.kind) -}}
{{- end }}{{- /* if[1] */ -}}
{{- end -}} {{- /* /if[0]*/ -}}
{{- end -}}{{- /* /define[0] */ -}}