kubernetes-sigs / cluster-api-provider-ibmcloud

Cluster API Provider for IBM Cloud
https://cluster-api-ibmcloud.sigs.k8s.io
Apache License 2.0
62 stars 84 forks source link

Enhance linting to cover yaml files #1497

Open Prajyot-Parab opened 1 year ago

Prajyot-Parab commented 1 year ago

/kind bug /area provider/ibmcloud

What steps did you take and what happened:

What did you expect to happen:

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

Environment:

Prajyot-Parab commented 1 year ago

/good-first-issue

k8s-ci-robot commented 1 year ago

@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:

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](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1497): >/good-first-issue Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
yuanning6 commented 1 year ago

/assign @yuanning6

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

Prajyot-Parab commented 1 year ago

@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 https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/commit/7cd7fcc1c0448df9caae393fa63720a874b36c85

yuanning6 commented 1 year ago

@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 commented 1 year ago

@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 commented 12 months ago

@Prajyot-Parab Sure! I did some implementations and made a PR https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/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 commented 12 months ago

@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 commented 12 months ago

@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 commented 2 months ago

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 commented 1 month ago

/cc @priyanshikhetwani

priyanshikhetwani commented 1 month ago

/assign

priyanshikhetwani commented 1 month ago

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 commented 1 month ago

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