Skip to content

Commit 6b633b1

Browse files
committed
fix(cozy-lib): add extraDnsNames type guard, quote group, update README
Add kindIs slice check for extraDnsNames to match dnsNames guard. Quote the hardcoded group field for full output consistency. Update README to enumerate all helper categories in the library. Signed-off-by: Arsolitt <[email protected]>
1 parent ad67636 commit 6b633b1

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

‎packages/library/cozy-lib/README.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22

33
Shared Helm library chart for Cozystack platform charts.
44

5-
Provides reusable template helpers — TLS certificate management (cert-manager integration)
6-
and RBAC/quota utilities. Helpers are documented inline in their respective `_*.tpl` files.
5+
Provides reusable template helpers:
6+
7+
- **Input validation** (`_checkinput.tpl`) — input validation utilities
8+
- **CozyStack config** (`_cozyconfig.tpl`) — platform configuration helpers
9+
- **Network** (`_network.tpl`) — network configuration helpers
10+
- **RBAC** (`_rbac.tpl`) — role-based access control helpers
11+
- **Resource presets** (`_resourcepresets.tpl`) — resource preset management
12+
- **Resources** (`_resources.tpl`) — Kubernetes resource helpers
13+
- **Strings** (`_strings.tpl`) — string manipulation utilities
14+
- **TLS** (`_tls.tpl`) — cert-manager Certificate CR generation and TLS secret name resolution
15+
16+
Helpers are documented inline in their respective `_*.tpl` files.
717

818
This chart has no configurable `values.yaml` parameters; all configuration is passed
919
via template arguments at call sites.

‎packages/library/cozy-lib/templates/_tls.tpl‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Parameters:
4444
{{- if not (kindIs "slice" .dnsNames) -}}
4545
{{- fail "ERROR: \"dnsNames\" must be a list for cozy-lib.tls.certificate. Got a string — wrap it in a list." -}}
4646
{{- end -}}
47+
{{- if and .extraDnsNames (not (kindIs "slice" .extraDnsNames)) -}}
48+
{{- fail "ERROR: \"extraDnsNames\" must be a list for cozy-lib.tls.certificate. Got a string — wrap it in a list." -}}
49+
{{- end -}}
4750
{{- if not .issuerRef -}}
4851
{{- fail "ERROR: \"issuerRef\" is required for cozy-lib.tls.certificate. Provide a dict with \"name\" and \"kind\"." -}}
4952
{{- end -}}
@@ -90,7 +93,7 @@ spec:
9093
issuerRef:
9194
name: {{ .issuerRef.name | quote }}
9295
kind: {{ .issuerRef.kind | quote }}
93-
group: cert-manager.io
96+
group: {{ "cert-manager.io" | quote }}
9497
{{- end }}
9598

9699
{{/*

‎packages/tests/cozy-lib-tests/tests/tls_test.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,23 @@ tests:
478478
asserts:
479479
- failedTemplate:
480480
errorMessage: 'ERROR: "dnsNames" must be a list for cozy-lib.tls.certificate. Got a string — wrap it in a list.'
481+
482+
# String extraDnsNames triggers a type error
483+
- it: errors when extraDnsNames is a string instead of a list
484+
release:
485+
name: test-release
486+
namespace: tenant-test
487+
set:
488+
_cluster: {}
489+
_namespace: {}
490+
tls:
491+
name: string-extra-dns-tls
492+
dnsNames:
493+
- svc.example
494+
issuerRef:
495+
name: selfsigned-cluster-issuer
496+
kind: ClusterIssuer
497+
extraDnsNames: extra.example.com
498+
asserts:
499+
- failedTemplate:
500+
errorMessage: 'ERROR: "extraDnsNames" must be a list for cozy-lib.tls.certificate. Got a string — wrap it in a list.'

0 commit comments

Comments
 (0)