From a3d093702c6d2642964b60f74fc40c5de73f77c0 Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Wed, 13 Aug 2025 21:27:56 +0000 Subject: [PATCH] refactor(chart): replace the netcat command with the busybox wget variant (#26) ### Description of the change replace the netcat command with wget commands. ### Benefits Less noise in the log(s) ### Possible drawbacks No limitations. As far as I am aware. - Fixes # https://gitea.com/gitea/helm-actions/pulls/23#issuecomment-1027779 ### Additional information As the PR Title suggests, it replaces the netcat command to a wget command which makes the noise in the log stop. ### Checklist - [X] Parameters are documented in the `values.yaml` and added to the `README.md` using [readme-generator-for-helm](https://github.com/bitnami-labs/readme-generator-for-helm) - [X] Breaking changes are documented in the `README.md` - [X] Helm templating unittests are added (required when changing anything in `templates` folder) - [X] Bash unittests are added (required when changing anything in `scripts` folder) - [X] All added template resources MUST render a namespace in metadata Co-authored-by: Daan Selen Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/26 Reviewed-by: ChristopherHX Co-authored-by: Daan Selen Co-committed-by: Daan Selen --- templates/_helpers.tpl | 20 -------------------- templates/statefulset.yaml | 7 +++++-- unittests/helm/statefulset.yaml | 21 +++++++++++++++------ 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 2f3a52b..599ee36 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -86,23 +86,3 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- define "gitea.actions.local_root_url" -}} {{- .Values.giteaRootURL -}} {{- end -}} - -{{/* -Parse the http url to hostname + port separated by space for the nc command -*/}} -{{- define "gitea.actions.nc" -}} -{{- $url := include "gitea.actions.local_root_url" . | urlParse -}} -{{- $host := get $url "host" -}} -{{- $scheme := get $url "scheme" -}} -{{- $port := "80" -}} -{{- if contains ":" $host -}} - {{- $hostAndPort := regexSplit ":" $host 2 -}} - {{- $host = index $hostAndPort 0 -}} - {{- $port = index $hostAndPort 1 -}} -{{- else if eq $scheme "https" -}} - {{- $port = "443" -}} -{{- else if eq $scheme "http" -}} - {{- $port = "80" -}} -{{- end -}} -{{- printf "%s %s" $host $port -}} -{{- end -}} diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index 6c33e0b..7bc04ea 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -37,9 +37,12 @@ spec: - sh - -c - | - while ! nc -z {{ include "gitea.actions.nc" . }}; do - sleep 5 + echo 'Trying to reach Gitea on {{ include "gitea.actions.local_root_url" . }}' + while ! wget --no-check-certificate -qO- {{ include "gitea.actions.local_root_url" . }}; do + sleep 3 + echo "Trying again in 3 seconds..." done + echo "Gitea has been reached!" containers: - name: act-runner image: "{{ .Values.statefulset.actRunner.repository }}:{{ .Values.statefulset.actRunner.tag }}" diff --git a/unittests/helm/statefulset.yaml b/unittests/helm/statefulset.yaml index e93f593..59ff76d 100644 --- a/unittests/helm/statefulset.yaml +++ b/unittests/helm/statefulset.yaml @@ -92,9 +92,12 @@ tests: - equal: path: spec.template.spec.initContainers[0].command[2] value: | - while ! nc -z git.example.com 80; do - sleep 5 + echo 'Trying to reach Gitea on http://git.example.com' + while ! wget --no-check-certificate -qO- http://git.example.com; do + sleep 3 + echo "Trying again in 3 seconds..." done + echo "Gitea has been reached!" - it: renders a StatefulSet https (with correct GITEA_INSTANCE_URL env from giteaRootURL) template: templates/statefulset.yaml set: @@ -117,9 +120,12 @@ tests: - equal: path: spec.template.spec.initContainers[0].command[2] value: | - while ! nc -z git.example.com 443; do - sleep 5 + echo 'Trying to reach Gitea on https://git.example.com' + while ! wget --no-check-certificate -qO- https://git.example.com; do + sleep 3 + echo "Trying again in 3 seconds..." done + echo "Gitea has been reached!" - it: renders a StatefulSet https (with correct GITEA_INSTANCE_URL env from giteaRootURL) template: templates/statefulset.yaml set: @@ -142,9 +148,12 @@ tests: - equal: path: spec.template.spec.initContainers[0].command[2] value: | - while ! nc -z git.example.com 8443; do - sleep 5 + echo 'Trying to reach Gitea on https://git.example.com:8443' + while ! wget --no-check-certificate -qO- https://git.example.com:8443; do + sleep 3 + echo "Trying again in 3 seconds..." done + echo "Gitea has been reached!" - it: allows adding custom environment variables to the docker-in-docker container template: templates/statefulset.yaml set: