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

yaml templates using text/template and sprig #415

Open
webframp opened this issue Mar 27, 2023 · 0 comments
Open

yaml templates using text/template and sprig #415

webframp opened this issue Mar 27, 2023 · 0 comments

Comments

@webframp
Copy link

Hey there,

Sorry for making an issue if this seems unrelated or has been answered, I searched around and have asked other places to no avail so far.

I deal quite a bit with yaml template files that have inline template syntax, based on text/template and sprig, you can blame kubernetes.

Example snippet:

{{- if .featureflag}}
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: app-operator
  name: app-operator
  namespace: app-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-operator
  strategy:
    type: RollingUpdate
  template:
  ...

or another example:

      containers:
      - name: coredns
        {{- if regexMatch "^1\\.2[34]$" .k8sversion }}
        image: coredns:v1.8.7
        {{- end }}
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            memory: 170Mi
          requests:
            cpu: 100m
            memory: 70Mi

I have yet to find a great mode configuration for working with these and am wondering what people who use go-mode are using, if they have this same scenario.

What I've investigated:

First was of course yaml-mode of course, which is the best I can get so far, but occasionally breaks on some template syntax. This is what I'm currently using by default.

Next I found #184 which was talking about go template syntax in web files, but web-mode specifically does not support yaml syntax and it seems it will not be added: fxbois/web-mode#934

Third I was directed to poly-ansible that uses polymode, which seems pretty promising but: 1) pulls in ansible-mode as a dependency and 2) is for jinja2 templates, which while similar are not quite the same as go templates.

Does anyone else using go-mode have this same problem?

No offense if you choose to just close but thanks for any info that might help

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

No branches or pull requests

1 participant