Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set unique placeholder values for each substitution #801

Merged
merged 2 commits into from
Nov 2, 2024
Merged

Conversation

allenporter
Copy link
Owner

Fix an issue where substitution values (that are from secrets or can't be found) were not unique which may result in resource names that are set with the same value. This may mask bugs if users do not set resource values to the same thing when using secrets.

Fixes #754

Copy link
Contributor

github-actions bot commented Nov 2, 2024

--- tests/testdata/cluster/clusters/prod Kustomization: flux-system/flux-system Kustomization: flux-system/apps

+++ tests/testdata/cluster/clusters/prod Kustomization: flux-system/flux-system Kustomization: flux-system/apps

@@ -15,12 +15,14 @@

   postBuild:
     substitute:
       cluster_env: production
     substituteFrom:
     - kind: ConfigMap
       name: cluster-config
+    - kind: Secret
+      name: cluster-secrets
   prune: true
   sourceRef:
     kind: GitRepository
     name: flux-system
   timeout: 5m0s
   wait: true
--- tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN3..-staging

+++ tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN3..-staging

@@ -0,0 +1,18 @@

+---
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: -.PLACEHOLDER_SECRET_DOMAIN3..-staging
+spec:
+  commonName: ..PLACEHOLDER_SECRET_DOMAIN3..
+  dnsNames:
+  - ..PLACEHOLDER_SECRET_DOMAIN3..
+  - '*...PLACEHOLDER_SECRET_DOMAIN3..'
+  issuerRef:
+    kind: ClusterIssuer
+    name: letsencrypt-staging
+  secretName: -.PLACEHOLDER_SECRET_DOMAIN3..-staging-tls
+
--- tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN4..-staging

+++ tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN4..-staging

@@ -0,0 +1,18 @@

+---
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: -.PLACEHOLDER_SECRET_DOMAIN4..-staging
+spec:
+  commonName: ..PLACEHOLDER_SECRET_DOMAIN4..
+  dnsNames:
+  - ..PLACEHOLDER_SECRET_DOMAIN4..
+  - '*...PLACEHOLDER_SECRET_DOMAIN4..'
+  issuerRef:
+    kind: ClusterIssuer
+    name: letsencrypt-staging
+  secretName: -.PLACEHOLDER_SECRET_DOMAIN4..-staging-tls
+

Copy link
Contributor

github-actions bot commented Nov 2, 2024

--- tests/testdata/cluster/clusters/prod Kustomization: flux-system/flux-system Kustomization: flux-system/apps

+++ tests/testdata/cluster/clusters/prod Kustomization: flux-system/flux-system Kustomization: flux-system/apps

@@ -15,12 +15,14 @@

   postBuild:
     substitute:
       cluster_env: production
     substituteFrom:
     - kind: ConfigMap
       name: cluster-config
+    - kind: Secret
+      name: cluster-secrets
   prune: true
   sourceRef:
     kind: GitRepository
     name: flux-system
   timeout: 5m0s
   wait: true
--- tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN3..-staging

+++ tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN3..-staging

@@ -0,0 +1,18 @@

+---
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: -.PLACEHOLDER_SECRET_DOMAIN3..-staging
+spec:
+  commonName: ..PLACEHOLDER_SECRET_DOMAIN3..
+  dnsNames:
+  - ..PLACEHOLDER_SECRET_DOMAIN3..
+  - '*...PLACEHOLDER_SECRET_DOMAIN3..'
+  issuerRef:
+    kind: ClusterIssuer
+    name: letsencrypt-staging
+  secretName: -.PLACEHOLDER_SECRET_DOMAIN3..-staging-tls
+
--- tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN4..-staging

+++ tests/testdata/cluster/apps/prod Kustomization: flux-system/apps Certificate: flux-system/-.PLACEHOLDER_SECRET_DOMAIN4..-staging

@@ -0,0 +1,18 @@

+---
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: -.PLACEHOLDER_SECRET_DOMAIN4..-staging
+spec:
+  commonName: ..PLACEHOLDER_SECRET_DOMAIN4..
+  dnsNames:
+  - ..PLACEHOLDER_SECRET_DOMAIN4..
+  - '*...PLACEHOLDER_SECRET_DOMAIN4..'
+  issuerRef:
+    kind: ClusterIssuer
+    name: letsencrypt-staging
+  secretName: -.PLACEHOLDER_SECRET_DOMAIN4..-staging-tls
+

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.39%. Comparing base (0544971) to head (49ab913).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #801      +/-   ##
==========================================
- Coverage   93.40%   93.39%   -0.01%     
==========================================
  Files          20       20              
  Lines        2288     2287       -1     
==========================================
- Hits         2137     2136       -1     
  Misses        151      151              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@allenporter allenporter merged commit 8d46755 into main Nov 2, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

in Replace: id matched 2 resources error can still be reached
2 participants