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

Introduce a zarf prepare lint command #2064

Closed
3 of 5 tasks
Racer159 opened this issue Oct 11, 2023 · 10 comments
Closed
3 of 5 tasks

Introduce a zarf prepare lint command #2064

Racer159 opened this issue Oct 11, 2023 · 10 comments
Assignees
Labels
enhancement ✨ New feature or request
Milestone

Comments

@Racer159
Copy link
Contributor

Racer159 commented Oct 11, 2023

Is your feature request related to a problem? Please describe.

We should introduce a zarf prepare lint command that will look at a zarf.yaml file and then error or warn when a zarf.yaml is out of spec with best practices.

Describe the solution you'd like

  • Given I have a zarf.yaml that is not following best practices
  • When I run zarf prepare lint on that file
  • Then I receive a list of notes, warnings or errors according to the following:
  • error: invalid package schema
  • warning: flagged package warning (i.e. from p.warnings / deprecations)
  • warning: unpinned dependencies (repos or images without a tagged reference)
  • warning: files without pinned shasums
  • note: variables, packages, actions and components without descriptions

Describe alternatives you've considered

We could publish these as docs, but having them coded into a command allows them to be run in CI and updated without people needing to go back and read a docs page.

Additional context

This will help package development scale and push the Zarf community's view of what makes a "good" Zarf package.

@Racer159
Copy link
Contributor Author

It may be worth it to yamllint downstream manifests and values files that are directly provided to Zarf as well https://kubernetes.slack.com/archives/C03B6BJAUJ3/p1697579246332669?thread_ts=1683149646.315369&cid=C03B6BJAUJ3

@AustinAbro321
Copy link
Contributor

I would also like to give the user the line number in the future

Racer159 added a commit that referenced this issue Nov 29, 2023
## Description

Intent of this PR is to introduce the command zarf prepare lint, with
the ability to validate the zarf schema

## Related Issue

Relates to #2064  #1667 

## Type of change

- [X] New feature (non-breaking change which adds functionality)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [ ] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

---------

Co-authored-by: Barry Waldbaum <barry@waldbaum.com>
Co-authored-by: Wayne Starr <Racer159@users.noreply.github.com>
Co-authored-by: Lucas Rodriguez <lucas.rodriguez9616@gmail.com>
Co-authored-by: razzle <harry@razzle.cloud>
@AustinAbro321
Copy link
Contributor

AustinAbro321 commented Nov 29, 2023

For checking unpinned repos I'm leaning towards just checking if the repo doesn't contain "@" or "/-/". Could result in some false negatives since repos can have "@" in the name. This should cover github, dev.azure, and gitlab repos. Any source control sites popular among our users that I should take a look at @Racer159? Those would likely have false positives if they urls aren't built like github / gitlab

@AustinAbro321
Copy link
Contributor

We may want either run every combination of architecture or pass in architectures from lint

@AustinAbro321
Copy link
Contributor

We should warn if variables are not being used anywhere

@AustinAbro321
Copy link
Contributor

We can also use variable defaults / set values we can get to make sure that the downstream mainfests / helmcharts are valid yaml

@AustinAbro321
Copy link
Contributor

AustinAbro321 commented Dec 5, 2023

I would like to allow yaml extensions in the schema. They will work currently but give a schema error https://docs.docker.com/compose/compose-file/11-extension/.

This was resolved by: #2217

Racer159 added a commit that referenced this issue Dec 18, 2023
…prepare lint` (#2171)

## Description
Adding warnings for unpinned images, files and repos

## Related Issue

Relates to #2064 

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed

---------

Co-authored-by: Barry Waldbaum <barry@waldbaum.com>
Co-authored-by: Wayne Starr <Racer159@users.noreply.github.com>
Co-authored-by: Lucas Rodriguez <lucas.rodriguez9616@gmail.com>
Co-authored-by: razzle <harry@razzle.cloud>
Racer159 added a commit that referenced this issue Jan 10, 2024
## Description

Support yaml extension in lint following these rules
https://docs.docker.com/compose/compose-file/11-extension/

## Related Issue

Relates to #2064 

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [ ] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

---------

Co-authored-by: Wayne Starr <Racer159@users.noreply.github.com>
@AustinAbro321
Copy link
Contributor

verify that the zarf-config.yaml / toml / ini / json has at least package.deploy or package.create

@Racer159
Copy link
Contributor Author

Tying this to this since this is the other side of variables linting: #2096

@AustinAbro321
Copy link
Contributor

Command has been introduced. Putting further lints in the other issues. Moving flagged package warning (i.e. from p.warnings / deprecations) will go in #2485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
Status: Done
Status: No status
Development

No branches or pull requests

2 participants