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

fix: Allow users to optionally override templates #1340

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

wasurerarenai
Copy link
Contributor

Looks like the logic was reversed in #1319. That change allowed non-existant files in bootstrap/templates to be created, but couldn't override existing files. The inputs need to be swapped to allow the overrides to be applied with preference (if they exist).

This affect can be seen in makejinja's examples:

This allowed me to apply a patch to the ingress-nginx instances without changing the source template files.

$ cat kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml 
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ./helmrelease.yaml

$ grep input makejinja.toml 
inputs = ["./bootstrap/overrides","./bootstrap/templates"]

$ cat bootstrap/overrides/kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml.j2 
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ./helmrelease.yaml
patches:
  - path: helmrelease-values.yaml
    target:
      kind: HelmRelease

$ cat bootstrap/overrides/kubernetes/apps/network/ingress-nginx/internal/helmrelease-values.yaml.j2 
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: ingress-nginx-internal
spec:
  values:
    controller:
      replicaCount: 2

$ task configure -y

$ cat kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml 
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ./helmrelease.yaml
patches:
  - path: helmrelease-values.yaml
    target:
      kind: HelmRelease

$ cat kubernetes/apps/network/ingress-nginx/internal/helmrelease-values.yaml
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: ingress-nginx-internal
spec:
  values:
    controller:
      replicaCount: 2

@onedr0p
Copy link
Owner

onedr0p commented Feb 23, 2024

That makes sense, thanks for providing an update!

@onedr0p onedr0p merged commit 4690755 into onedr0p:main Feb 23, 2024
4 checks passed
@wasurerarenai wasurerarenai deleted the Wasurerarenai-patch-2 branch March 1, 2024 08:31
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.

None yet

2 participants