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

Replace yamllint with yamlfmt #1245

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

bennerv
Copy link
Contributor

@bennerv bennerv commented Feb 5, 2025

What this PR does

Replaces the megalinter yamllint with yamlfmt so that instead of us doing manual work to format yaml files correctly, we can just let the computers do it for us.

---
# MegaLinter GitHub Action configuration file
# More info at https://oxsecurity.github.io/megalinter
name: mega-linter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: mega-linter
name: yamlfmt

contents: read
jobs:
build:
name: mega-linter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: mega-linter
name: yamlfmt

- name: 'run yamlfmt'
run: |-
make yamlfmt
git diff --exit-code\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the trailing slash expected?

- name: {{ .svc.rg }}
subscription: {{ .svc.subscription }}
aksCluster: {{ .aksName }}
- name: {? {.svc.rg: ''} : ''}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes with go templates conditional/ternary operators expected as part of this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also changes the behavior where instead of the template failing if the variable is not set, it'll set defaults to empty strings which may not produce desired outcome. Seems like its better to let it fail than to use empty strings and hope for the best?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the templates fail and should fail if a variable can't be resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yaml formatter changed this for us. I think we have to convert things to strings as a result.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow TIL https://yaml.org/spec/1.2.2/#rule-e-node
I didn't think this was valid YAML... To essentially this not only add some yaml ternary blocks but breaks our templating?

Is there a rule we can exclude from the formatter to avoid it messing with our templating?

@jfchevrette
Copy link
Collaborator

+1 from me

- name: 'run yamlfmt'
run: |-
make yamlfmt
git diff --exit-code\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small UX suggestion :)

Suggested change
git diff --exit-code\
git diff --exit-code
[ $? -ne 0 ] && echo "YAML formatting needed. Please run `make yamlfmt` to resolve automatically"

Copy link

github-actions bot commented Feb 5, 2025

Please rebase pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants