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

[improvement request] detect template strings #129

Open
gajus opened this issue Nov 18, 2021 · 2 comments
Open

[improvement request] detect template strings #129

gajus opened this issue Nov 18, 2021 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gajus
Copy link

gajus commented Nov 18, 2021

Many templating frameworks that interpolate yaml depend on {{ foo }} syntax to define directives, e.g.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  name: contra-web-review-storybook-$DEPLOYMENT_SLUG
  namespace: argocd
spec:
  destination:
    namespace: default
    server: {{ .Values.spec.destination.server | quote }}

In these cases, eslint-plugin-yml will produce the following errors:

/Users/gajus/Documents/dev/contra/contra-web-app/bin/contra-web-app-review-template.yaml
  11:14  error  Empty mapping values are forbidden  yml/no-empty-mapping-value
  11:14  error  The key must be a string            yml/require-string-key
  11:15  error  Empty mapping values are forbidden  yml/no-empty-mapping-value

It would be desirable to have an option to recognize this special syntax and treat it as a string literal.

@ota-meshi
Copy link
Owner

I think it's good if it's possible, but I think it's difficult if there is no parser that can parse it well.

@ota-meshi ota-meshi added the enhancement New feature or request label Nov 18, 2021
@gajus
Copy link
Author

gajus commented Jan 5, 2022

This specific problem is a non-issue b/c I can replace

server: {{ .Values.spec.destination.server | quote }}

with

server: '{{ .Values.spec.destination.server }}'

However, the one that I cannot figure out a workaround for is this one:

apiVersion: v1
kind: Service
metadata:
  labels:
    {{- include "app.resource_labels" . | indent 4}}
  name: '{{.Release.Name}}'
spec:
  ports:
    - name: industry-report-2021-web-app
      port: 80
      protocol: TCP
      targetPort: 80
  selector:
    {{- include "app.selector_labels" . | indent 4}}

@ota-meshi ota-meshi added the help wanted Extra attention is needed label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants