The files in templates/gitea/ used a mix of naming styles: lowercase concatenations (poddisruptionbudget.yaml, serviceaccount.yaml, servicemonitor.yaml, pvc.yaml), camelCase (httpService.yaml, sshService.yaml) and kind-suffixed names (gpg-secret.yaml, metrics-secret.yaml). It was therefore not obvious from a file name which Kubernetes resource it renders, and the naming contradicted the camelCase convention the Gateway API templates already follow. Files are now named after the kind they render, with a lowercase suffix distinguishing several resources of the same kind: config.yaml -> secret_config.yaml + secret_inlineConfig.yaml gpg-secret.yaml -> secret_gpg.yaml init.yaml -> secret_init.yaml metrics-secret.yaml -> secret_metrics.yaml httpService.yaml -> service_http.yaml sshService.yaml -> service_ssh.yaml poddisruptionbudget.yaml -> podDisruptionBudget.yaml pvc.yaml -> persistentVolumeClaim.yaml serviceaccount.yaml -> serviceAccount.yaml servicemonitor.yaml -> serviceMonitor.yaml config.yaml rendered two Secrets from a single file, which forced every unit test to address them via documentIndex. It is split so that each file renders exactly one resource. The rendered manifests are unchanged; only file names and the references to them were touched. This includes the checksum/config annotation in deployment.yaml and all helm unit test suites. The HA guard assertions had to move from deployment.yaml to secret_config.yaml: Helm sorts templates in reverse alphabetical order, so secret_config.yaml is now rendered before deployment.yaml and the fail() is reported for that file directly instead of bubbling up through the include chain of the Deployment. Users relying on the template paths (e.g. `helm template --show-only` or post-renderers) have to adjust to the new file names. Co-authored-by: Copilot <copilot@github.com>
71 lines
2.0 KiB
YAML
71 lines
2.0 KiB
YAML
suite: ServiceMonitor template (monitoring enabled)
|
|
release:
|
|
name: gitea-unittests
|
|
namespace: testing
|
|
templates:
|
|
- templates/gitea/serviceMonitor.yaml
|
|
tests:
|
|
- it: renders unsecure ServiceMonitor if gitea.metrics.token nil
|
|
set:
|
|
gitea.metrics.enabled: true
|
|
gitea.metrics.token:
|
|
gitea.metrics.serviceMonitor.enabled: true
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- documentIndex: 0
|
|
containsDocument:
|
|
kind: ServiceMonitor
|
|
apiVersion: monitoring.coreos.com/v1
|
|
name: gitea-unittests
|
|
- isNotNullOrEmpty:
|
|
path: metadata.labels
|
|
- equal:
|
|
path: spec.endpoints
|
|
value:
|
|
- port: http
|
|
- it: renders unsecure ServiceMonitor if gitea.metrics.token empty
|
|
set:
|
|
gitea.metrics.enabled: true
|
|
gitea.metrics.token: ""
|
|
gitea.metrics.serviceMonitor.enabled: true
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- documentIndex: 0
|
|
containsDocument:
|
|
kind: ServiceMonitor
|
|
apiVersion: monitoring.coreos.com/v1
|
|
name: gitea-unittests
|
|
- isNotNullOrEmpty:
|
|
path: metadata.labels
|
|
- equal:
|
|
path: spec.endpoints
|
|
value:
|
|
- port: http
|
|
- it: renders secure ServiceMonitor if gitea.metrics.token not empty
|
|
set:
|
|
gitea.metrics.enabled: true
|
|
gitea.metrics.token: "test-token"
|
|
gitea.metrics.serviceMonitor.enabled: true
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- documentIndex: 0
|
|
containsDocument:
|
|
kind: ServiceMonitor
|
|
apiVersion: monitoring.coreos.com/v1
|
|
name: gitea-unittests
|
|
- isNotNullOrEmpty:
|
|
path: metadata.labels
|
|
- equal:
|
|
path: spec.endpoints
|
|
value:
|
|
- port: http
|
|
authorization:
|
|
type: Bearer
|
|
credentials:
|
|
name: gitea-unittests-metrics-secret
|
|
key: token
|
|
optional: false
|