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

Enhance linting to cover yaml files #1497

Open
Prajyot-Parab opened this issue Nov 16, 2023 · 14 comments · May be fixed by #2072
Open

Enhance linting to cover yaml files #1497

Prajyot-Parab opened this issue Nov 16, 2023 · 14 comments · May be fixed by #2072
Assignees
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@Prajyot-Parab
Copy link
Contributor

/kind bug
/area provider/ibmcloud

What steps did you take and what happened:

  • Enhance linting to cover yaml files (to avoid issues as - 7cd7fcc)

What did you expect to happen:

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Cluster-api version:
  • Minikube/KIND version:
  • Kubernetes version: (use kubectl version):
  • OS (e.g. from /etc/os-release):
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/provider/ibmcloud Issues or PRs related to ibmcloud provider labels Nov 16, 2023
@Prajyot-Parab
Copy link
Contributor Author

/good-first-issue

@k8s-ci-robot
Copy link
Contributor

@Prajyot-Parab:
This request has been marked as suitable for new contributors.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/good-first-issue

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Nov 16, 2023
@mkumatag mkumatag added this to the Next milestone Nov 17, 2023
@yuanning6
Copy link

/assign @yuanning6

I'd love to help fix this issue! Can I get some guide about where to start?

@Prajyot-Parab
Copy link
Contributor Author

Prajyot-Parab commented Nov 23, 2023

@yuanning6 You can start by checking the other linters we have - https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/.golangci.yml

can run make lint target to see the behavior

we want to do same thing for yaml files to avoid issues such as 7cd7fcc

@yuanning6
Copy link

@Prajyot-Parab Thank you so much for your guidance!

I found yamllint is a popular tool to lint yaml files, can I start with this? And should I make the lint rules very strict or kind of loose?

@Prajyot-Parab
Copy link
Contributor Author

@Prajyot-Parab Thank you so much for your guidance!

I found yamllint is a popular tool to lint yaml files, can I start with this? And should I make the lint rules very strict or kind of loose?

Yes you can start with whatever is the relevant tool, lets start with loose rules and we will make them stricter going ahead as and when required.

@yuanning6
Copy link

@Prajyot-Parab Sure! I did some implementations and made a PR #1521, it's just for you to have an overview and see if I'm on the right direction. Please let me know any changes I should make!

@Prajyot-Parab
Copy link
Contributor Author

@Prajyot-Parab Sure! I did some implementations and made a PR #1521, it's just for you to have an overview and see if I'm on the right direction. Please let me know any changes I should make!

I will take a look at this today, thanks!

@yuanning6
Copy link

@Prajyot-Parab Sure! I did some implementations and made a PR #1521, it's just for you to have an overview and see if I'm on the right direction. Please let me know any changes I should make!

I will take a look at this today, thanks!

Thank you! :))

@Amulyam24
Copy link
Contributor

The tool used for listing yaml is yamlint can be installed via https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint

Checking on how to consume this in CI or if there is a better to which can be installed and used easily.

@Amulyam24 Amulyam24 removed their assignment Oct 8, 2024
@Amulyam24
Copy link
Contributor

/cc @priyanshikhetwani

@priyanshikhetwani
Copy link

/assign

@priyanshikhetwani
Copy link

priyanshikhetwani commented Oct 9, 2024

yamllint will check YAML files for formatting issues, syntax errors, and key-value pair problems.
1:1 warning missing document start "---" (document-start) 12:10 error trailing spaces (trailing-spaces) 18:14 error too many spaces after colon (colons) 38:15 error too many spaces after colon (colons) 56:21 error too many spaces after colon (colons) 61:21 error too many spaces after colon (colons) 169:1 error trailing spaces (trailing-spaces)

KubeLinter will check Kubernetes YAML files and Helm charts for misconfigurations and programming errors.

/Users/priyanshikhetwani/Desktop/cluster-api-provider_ibmcloud/cluster-api-provider-ibmcloud/config/default/manager_credentials_patch.yaml: (object: system/controller-manager apps/v1, Kind=Deployment) container "manager" is not set to runAsNonRoot (check: run-as-non-root, remediation: Set runAsUser to a non-zero number and runAsNonRoot to true in your pod or container securityContext. Refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ for details.)

/Users/priyanshikhetwani/Desktop/cluster-api-provider_ibmcloud/cluster-api-provider-ibmcloud/config/default/manager_credentials_patch.yaml: (object: system/controller-manager apps/v1, Kind=Deployment) container "manager" has cpu request 0 (check: unset-cpu-requirements, remediation: Set CPU requests and limits for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)

For this issue, we can use yamllint but for longer run kube-linter can be helpful as well.
Exploring more so i can find some tool for both the usecases.

@Amulyam24
Copy link
Contributor

@priyanshikhetwani do you think for basic syntax checks, we can get started with using yamllint?

@priyanshikhetwani priyanshikhetwani linked a pull request Dec 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment