-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: enable full offline lint of all resource types #10059
feat: enable full offline lint of all resource types #10059
Conversation
6563cd8
to
8e2f05b
Compare
8973fe4
to
1c6f498
Compare
b31c2ec
to
3eec7a6
Compare
cmd/argo/commands/lint.go
Outdated
@@ -35,6 +35,9 @@ func NewLintCommand() *cobra.Command { | |||
cat manifests.yaml | argo lint --kinds=workflows,cronworkflows -`, | |||
Run: func(cmd *cobra.Command, args []string) { | |||
client.Offline = offline | |||
if offline { | |||
client.OfflineFiles = args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea that all the files form a "linting context", do you even OfflineFiles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your contextual lint should be the default. No need to enable any flag. I think we can always do what line 39 does. This is always better and more correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the condition. It doesn't make sense indeed. The OfflineFiles
are only used when the "offline client" is used
3eec7a6
to
074530a
Compare
074530a
to
62a4f49
Compare
62a4f49
to
d4336a2
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions. |
Currently, the offline linting only works for Workflow because other resources (`WorkflowTemplate`, `ClusterWorkflowTemplate` and `CronWorkflow`) can depend on references to other resources. However, this behavior is very limiting in a CI context where a user may modify both a "top-level" file and its dependencies at the same time. The dependencies are fetched from the server and the validation fails. This PR extends the offline linter so that it uses the whole list of files passed as arguments in order to validate. This is useful in a GitOps context where a user can pass the whole list of Argo files to the CI check. Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
f9f5c31
to
00f7146
Compare
Hey @alexec. Any chance I could get another review of this? This would greatly improve performance, reliability and usefulness of the linter for us |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of these changes. @juliev0 do you want to review? If not, we can merge.
My feeling is that in the interest of moving more PRs along, if you find a PR you approve of, go ahead and merge it? (but if it's in an area of the code I've worked in, I'm definitely happy to review it first) |
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
argoproj#10059 was tested in very specific cases it seems because a couple things are wrong: - Linting directories does not work anymore - Resolving references in a namespace which doesn't show up in the given args, panics In this PR, I fix those issues but I also add functional tests that checks that all of these cases work from the cmd level I did not add to the `argo/lint/lint_test.go` tests and instead put the tests earlier down the line because the current tests do not cover the creation and configuration of the offline client Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
Currently, the offline linting only works for Workflow because other resources (
WorkflowTemplate
,ClusterWorkflowTemplate
andCronWorkflow
) can depend on references to other resources.However, the “online” behavior that fetches refs from the server is also very limiting in a CI context where a user may modify both a "top-level" file and its dependencies at the same time. The dependencies are fetched from the server and the validation fails.
This PR extends the offline linter so that it uses the whole list of files passed as arguments in order to validate. If a ref needs to be resolved, the linter will search through the given files.
This is useful in a GitOps context where a user can pass the whole list of Argo files to the CI check.
Signed-off-by: Julien Duchesne julien.duchesne@grafana.com
make pre-commit -B
to fix codegen and lint problems.If changes were requested, and you've made them, dismiss the review to get it reviewed again.